Skip to content

Commit 333f805

Browse files
committed
minor fix (when redirected path has non-ASCII char and conf.url is unicode) and bits along with pieces
1 parent 595f69f commit 333f805

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

lib/core/common.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,10 @@ def getUnicode(value, encoding=None, system=False, noneToNull=False):
18861886
if isinstance(value, unicode):
18871887
return value
18881888
elif isinstance(value, basestring):
1889-
return unicode(value, encoding or UNICODE_ENCODING, errors="replace")
1889+
try:
1890+
return unicode(value, encoding or kb.pageEncoding)
1891+
except:
1892+
return unicode(value, UNICODE_ENCODING, "replace")
18901893
else:
18911894
return unicode(value) # encoding ignored for non-basestring instances
18921895
else:
@@ -2511,7 +2514,7 @@ def openFile(filename, mode='r'):
25112514
"""
25122515

25132516
try:
2514-
return codecs.open(filename, mode, UNICODE_ENCODING, errors="replace")
2517+
return codecs.open(filename, mode, UNICODE_ENCODING, "replace")
25152518
except IOError:
25162519
errMsg = "there has been a file opening error for filename '%s'. " % filename
25172520
errMsg += "Please check %s permissions on a file " % ("write" if \

lib/core/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def urldecode(value, encoding=None):
7777
result = urllib.unquote_plus(value)
7878

7979
if isinstance(result, str):
80-
result = unicode(result, encoding or UNICODE_ENCODING, errors="replace")
80+
result = unicode(result, encoding or UNICODE_ENCODING, "replace")
8181

8282
return result
8383

lib/request/redirecthandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def http_error_302(self, req, fp, code, msg, headers):
7878
redurl = self._get_header_redirect(headers)
7979

8080
if not urlparse.urlsplit(redurl).netloc:
81-
redurl = urlparse.urljoin(conf.url, redurl)
81+
redurl = urlparse.urljoin(req.get_full_url(), redurl)
8282

8383
self._infinite_loop_check(req)
8484
self._ask_redirect_choice(code, redurl)

0 commit comments

Comments
 (0)