mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-27 06:17:22 +01:00
Fix #941 (Raw UTF-8 misinterpreted in HTML with explicitly specified encoding)
This commit is contained in:
parent
07a6deb2a6
commit
3f6d486fb8
1 changed files with 5 additions and 3 deletions
|
|
@ -158,7 +158,7 @@ def binary_to_text(self, base=0, depth=0):
|
|||
continue
|
||||
elif c == '\v':
|
||||
c = '\n'
|
||||
self.buf.write(c.encode('utf-8'))
|
||||
self.buf.write(c.encode('ascii', 'xmlcharrefreplace'))
|
||||
|
||||
elif state == 'get flags':
|
||||
if oc == 0:
|
||||
|
|
@ -258,7 +258,8 @@ def binary_to_text(self, base=0, depth=0):
|
|||
state = 'get attr'
|
||||
elif count > 0:
|
||||
if not in_censorship:
|
||||
self.buf.write(unicode(c).encode('utf-8'))
|
||||
self.buf.write(c.encode(
|
||||
'ascii', 'xmlcharrefreplace'))
|
||||
count -= 1
|
||||
if count == 0:
|
||||
if not in_censorship:
|
||||
|
|
@ -310,7 +311,8 @@ def binary_to_text(self, base=0, depth=0):
|
|||
path = self.item_path(doc)
|
||||
if m and frag:
|
||||
path += m + frag
|
||||
self.buf.write((u'"%s"' % path).encode('utf-8'))
|
||||
self.buf.write((u'"%s"' % path).encode(
|
||||
'ascii', 'xmlcharrefreplace'))
|
||||
state = 'get attr'
|
||||
return index
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue