Index: trunk/extensions/SwiftMedia/wmf/rewrite.py |
— | — | @@ -10,6 +10,7 @@ |
11 | 11 | from eventlet.green import urllib2 |
12 | 12 | import wmf.client |
13 | 13 | import time |
| 14 | +import urlparse |
14 | 15 | #from swift.common.utils import get_logger |
15 | 16 | |
16 | 17 | # Copy2 is hairy. If we were only opening a URL, and returning it, we could |
— | — | @@ -126,7 +127,13 @@ |
127 | 128 | # However, someone may have a formerly valid link to a file, so we |
128 | 129 | # should do them the favor of giving them a 404. |
129 | 130 | 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 | + |
131 | 138 | except urllib2.HTTPError,status: |
132 | 139 | if status.code == 404: |
133 | 140 | resp = webob.exc.HTTPNotFound('Expected original file not found') |