Merge commit '9cfcbd3929cd7fbea4e585f01e101a3dc5055ee1' into py23
This commit is contained in:
commit
13d894e74b
1 file changed
+11
-3
@@ -9,6 +9,7 @@ import logging
|
||||
import os
|
||||
import mimetypes
|
||||
import re
|
||||
import sys
|
||||
|
||||
import tornado
|
||||
import tornado.web
|
||||
@@ -29,6 +30,8 @@ try:
|
||||
except:
|
||||
unicode = str
|
||||
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
def fix_json_encode():
|
||||
"""
|
||||
This makes tornado.escape.json_encode use octoprint.util.JsonEncoding.encode as fallback in order to allow
|
||||
@@ -511,10 +514,15 @@ def _extended_header_value(value):
|
||||
|
||||
if value.lower().startswith("iso-8859-1'") or value.lower().startswith("utf-8'"):
|
||||
# RFC 5987 section 3.2
|
||||
from urllib import unquote
|
||||
try:
|
||||
from urllib import unquote
|
||||
except ImportError:
|
||||
from urllib.parse import unquote
|
||||
encoding, _, value = value.split("'", 2)
|
||||
return unquote(octoprint.util.to_str(value, encoding="iso-8859-1")).decode(encoding)
|
||||
|
||||
if PY3:
|
||||
return unquote(value, encoding=encoding)
|
||||
else:
|
||||
return unquote(octoprint.util.to_str(value, encoding="iso-8859-1")).decode(encoding)
|
||||
else:
|
||||
# no encoding provided, strip potentially present quotes and call it a day
|
||||
return octoprint.util.to_unicode(_strip_value_quotes(value), encoding="utf-8")
|
||||
|
||||
Reference in new issue
Block a user