mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Fix #941 (Raw UTF-8 misinterpreted in HTML with explicitly specified encoding)
This commit is contained in:
parent
07a6deb2a6
commit
3f6d486fb8
@ -158,7 +158,7 @@ class UnBinary(object):
|
|||||||
continue
|
continue
|
||||||
elif c == '\v':
|
elif c == '\v':
|
||||||
c = '\n'
|
c = '\n'
|
||||||
self.buf.write(c.encode('utf-8'))
|
self.buf.write(c.encode('ascii', 'xmlcharrefreplace'))
|
||||||
|
|
||||||
elif state == 'get flags':
|
elif state == 'get flags':
|
||||||
if oc == 0:
|
if oc == 0:
|
||||||
@ -258,7 +258,8 @@ class UnBinary(object):
|
|||||||
state = 'get attr'
|
state = 'get attr'
|
||||||
elif count > 0:
|
elif count > 0:
|
||||||
if not in_censorship:
|
if not in_censorship:
|
||||||
self.buf.write(unicode(c).encode('utf-8'))
|
self.buf.write(c.encode(
|
||||||
|
'ascii', 'xmlcharrefreplace'))
|
||||||
count -= 1
|
count -= 1
|
||||||
if count == 0:
|
if count == 0:
|
||||||
if not in_censorship:
|
if not in_censorship:
|
||||||
@ -310,7 +311,8 @@ class UnBinary(object):
|
|||||||
path = self.item_path(doc)
|
path = self.item_path(doc)
|
||||||
if m and frag:
|
if m and frag:
|
||||||
path += m + 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'
|
state = 'get attr'
|
||||||
return index
|
return index
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user