Show More
@@ -1284,6 +1284,26 b' def parsebool(s):' | |||||
1284 | """ |
|
1284 | """ | |
1285 | return _booleans.get(s.lower(), None) |
|
1285 | return _booleans.get(s.lower(), None) | |
1286 |
|
1286 | |||
|
1287 | _hexdig = '0123456789ABCDEFabcdef' | |||
|
1288 | _hextochr = dict((a + b, chr(int(a + b, 16))) | |||
|
1289 | for a in _hexdig for b in _hexdig) | |||
|
1290 | ||||
|
1291 | def _urlunquote(s): | |||
|
1292 | """unquote('abc%20def') -> 'abc def'.""" | |||
|
1293 | res = s.split('%') | |||
|
1294 | # fastpath | |||
|
1295 | if len(res) == 1: | |||
|
1296 | return s | |||
|
1297 | s = res[0] | |||
|
1298 | for item in res[1:]: | |||
|
1299 | try: | |||
|
1300 | s += _hextochr[item[:2]] + item[2:] | |||
|
1301 | except KeyError: | |||
|
1302 | s += '%' + item | |||
|
1303 | except UnicodeDecodeError: | |||
|
1304 | s += unichr(int(item[:2], 16)) + item[2:] | |||
|
1305 | return s | |||
|
1306 | ||||
1287 | class url(object): |
|
1307 | class url(object): | |
1288 | """Reliable URL parser. |
|
1308 | """Reliable URL parser. | |
1289 |
|
1309 | |||
@@ -1427,7 +1447,7 b' class url(object):' | |||||
1427 | 'path', 'query', 'fragment'): |
|
1447 | 'path', 'query', 'fragment'): | |
1428 | v = getattr(self, a) |
|
1448 | v = getattr(self, a) | |
1429 | if v is not None: |
|
1449 | if v is not None: | |
1430 |
setattr(self, a, url |
|
1450 | setattr(self, a, _urlunquote(v)) | |
1431 |
|
1451 | |||
1432 | def __repr__(self): |
|
1452 | def __repr__(self): | |
1433 | attrs = [] |
|
1453 | attrs = [] |
General Comments 0
You need to be logged in to leave comments.
Login now