r111145 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111144‎ | r111145 | r111146 >
Date:02:56, 10 February 2012
Author:ben
Status:ok
Tags:
Comment:
ripping apart and urlencoding the path before passing it back to ms5 to deal with \& signs correctly
Modified paths:
  • /trunk/extensions/SwiftMedia/wmf/rewrite.py (modified) (history)

Diff [purge]

Index: trunk/extensions/SwiftMedia/wmf/rewrite.py
@@ -10,6 +10,7 @@
1111 from eventlet.green import urllib2
1212 import wmf.client
1313 import time
 14+import urlparse
1415 #from swift.common.utils import get_logger
1516
1617 # Copy2 is hairy. If we were only opening a URL, and returning it, we could
@@ -126,7 +127,13 @@
127128 # However, someone may have a formerly valid link to a file, so we
128129 # should do them the favor of giving them a 404.
129130 try:
130 - upcopy = opener.open(reqorig.url)
 131+ # break apach the url, url-encode it, and put it back together
 132+ urlobj = list(urlparse.urlsplit(reqorig.url))
 133+ urlobj[2] = urllib2.quote(urlobj[2], '%/')
 134+ encodedurl = urlparse.urlunsplit(urlobj)
 135+ # ok, call the encoded url
 136+ upcopy = opener.open(encodedurl)
 137+
131138 except urllib2.HTTPError,status:
132139 if status.code == 404:
133140 resp = webob.exc.HTTPNotFound('Expected original file not found')

Sign-offs

UserFlagDate
😂inspected03:46, 8 March 2012

Follow-up revisions

RevisionCommit summaryAuthorDate
r113536Followup r111145, typo fixawjrichards22:45, 9 March 2012

Status & tagging log