https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111145
Revision: 111145 Author: ben Date: 2012-02-10 02:56:31 +0000 (Fri, 10 Feb 2012) Log Message: ----------- 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: trunk/extensions/SwiftMedia/wmf/rewrite.py =================================================================== --- trunk/extensions/SwiftMedia/wmf/rewrite.py 2012-02-10 01:35:13 UTC (rev 111144) +++ trunk/extensions/SwiftMedia/wmf/rewrite.py 2012-02-10 02:56:31 UTC (rev 111145) @@ -10,6 +10,7 @@ from eventlet.green import urllib2 import wmf.client import time +import urlparse #from swift.common.utils import get_logger # Copy2 is hairy. If we were only opening a URL, and returning it, we could @@ -126,7 +127,13 @@ # However, someone may have a formerly valid link to a file, so we # should do them the favor of giving them a 404. try: - upcopy = opener.open(reqorig.url) + # break apach the url, url-encode it, and put it back together + urlobj = list(urlparse.urlsplit(reqorig.url)) + urlobj[2] = urllib2.quote(urlobj[2], '%/') + encodedurl = urlparse.urlunsplit(urlobj) + # ok, call the encoded url + upcopy = opener.open(encodedurl) + except urllib2.HTTPError,status: if status.code == 404: resp = webob.exc.HTTPNotFound('Expected original file not found') _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs