Kaydet (Commit) 0564e123 authored tarafından Guido van Rossum's avatar Guido van Rossum

Added quote_plus() and unquote_plus(), to do space/plus substitutions

for form field values.
üst fbcfd52a
...@@ -693,6 +693,12 @@ def unquote(s): ...@@ -693,6 +693,12 @@ def unquote(s):
i = j+3 i = j+3
return string.joinfields(res, '') return string.joinfields(res, '')
def unquote_plus(s):
if '+' in s:
import regsub
s = regsub.gsub('+', ' ', s)
return unquote(s)
always_safe = string.letters + string.digits + '_,.-' always_safe = string.letters + string.digits + '_,.-'
def quote(s, safe = '/'): def quote(s, safe = '/'):
safe = always_safe + safe safe = always_safe + safe
...@@ -704,6 +710,14 @@ def quote(s, safe = '/'): ...@@ -704,6 +710,14 @@ def quote(s, safe = '/'):
res.append('%%%02x' % ord(c)) res.append('%%%02x' % ord(c))
return string.joinfields(res, '') return string.joinfields(res, '')
def quote_plus(s, safe = '/'):
if ' ' in s:
import regsub
s = regsub.gsub(' ', '+', s)
return quote(s, safe + '+')
else:
return quote(s, safe)
# Proxy handling # Proxy handling
def getproxies(): def getproxies():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment