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

for form field values.
This commit is contained in:
Guido van Rossum 1996-12-13 14:47:36 +00:00
parent fbcfd52a9a
commit 0564e12367
1 changed files with 14 additions and 0 deletions

View File

@ -693,6 +693,12 @@ def unquote(s):
i = j+3
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 + '_,.-'
def quote(s, safe = '/'):
safe = always_safe + safe
@ -704,6 +710,14 @@ def quote(s, safe = '/'):
res.append('%%%02x' % ord(c))
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
def getproxies():