import urllib as compat_urllib_parse
try:
from urllib.parse import urlparse as compat_urllib_parse_urlparse
import urllib as compat_urllib_parse
try:
from urllib.parse import urlparse as compat_urllib_parse_urlparse
# HACK: The following is the correct parse_qs implementation from cpython 3's stdlib.
# Python 2's version is apparently totally broken
def _parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
# HACK: The following is the correct parse_qs implementation from cpython 3's stdlib.
# Python 2's version is apparently totally broken
def _parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
qs, _coerce_result = qs, unicode
pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
r = []
qs, _coerce_result = qs, unicode
pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
r = []
return r
def compat_parse_qs(qs, keep_blank_values=False, strict_parsing=False,
return r
def compat_parse_qs(qs, keep_blank_values=False, strict_parsing=False,
parsed_result = {}
pairs = _parse_qsl(qs, keep_blank_values, strict_parsing,
parsed_result = {}
pairs = _parse_qsl(qs, keep_blank_values, strict_parsing,
for name, value in pairs:
if name in parsed_result:
parsed_result[name].append(value)
for name, value in pairs:
if name in parsed_result:
parsed_result[name].append(value)
- return "'" + s.replace("'", "'\"'\"'") + "'"
+ if re.match(r'^[-_\w./]+$', s):
+ return s
+ else:
+ return "'" + s.replace("'", "'\"'\"'") + "'"
userhome = os.path.join(os.path.dirname(userhome), path[1:i])
return userhome + path[i:]
userhome = os.path.join(os.path.dirname(userhome), path[1:i])
return userhome + path[i:]