summaryrefslogtreecommitdiffstats
path: root/module/network
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-10-24 16:30:09 +0200
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-10-24 16:30:09 +0200
commit3a4dab4477d6cbb437bafb602f2d6734bb10cb64 (patch)
tree1e877f77dcd53fe580d0409d0d0c39965e0ef9f4 /module/network
parentupdated setup script (diff)
downloadpyload-3a4dab4477d6cbb437bafb602f2d6734bb10cb64.tar.xz
HTTPRequest: skip BOM if response is 'Microsoft-UTF8' encoded
Diffstat (limited to 'module/network')
-rw-r--r--module/network/HTTPRequest.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/module/network/HTTPRequest.py b/module/network/HTTPRequest.py
index d8d57e76f..99197314f 100644
--- a/module/network/HTTPRequest.py
+++ b/module/network/HTTPRequest.py
@@ -19,7 +19,7 @@
import pycurl
-from codecs import getincrementaldecoder
+from codecs import getincrementaldecoder, lookup, BOM_UTF8
from urllib import quote, urlencode
from httplib import responses
from logging import getLogger
@@ -230,6 +230,9 @@ class HTTPRequest():
try:
#self.log.debug("Decoded %s" % encoding )
+ if lookup(encoding).name == 'utf-8' and rep.startswith(BOM_UTF8):
+ encoding = 'utf-8-sig'
+
decoder = getincrementaldecoder(encoding)("replace")
rep = decoder.decode(rep, True)