Fix a handful of additional encoding issues. I don't like patching

cssutils, but cssutils as-is insists on decoding the contents of
@imported files itself.  Another option would be to just encode
everything back into UTF-8 and then let cssutils decode it again, but
that seems even worse than a two-line patch.
This commit is contained in:
Marshall T. Vandegrift 2009-02-03 09:02:11 -05:00
parent 168ef41787
commit beb45413fe
3 changed files with 7 additions and 3 deletions

View File

@ -474,7 +474,7 @@ class LitWriter(object):
name = '/data/' + item.id
data = item.data
secnum = 0
if not isinstance(data, basestring):
if isinstance(data, etree._Element):
self._add_folder(name)
rebin = ReBinary(data, item, self._oeb, map=HTML_MAP)
self._add_file(name + '/ahc', rebin.ahc, 0)
@ -483,6 +483,8 @@ class LitWriter(object):
data = rebin.content
name = name + '/content'
secnum = 1
elif isinstance(data, unicode):
data = data.encode('utf-8')
self._add_file(name, data, secnum)
item.size = len(data)

View File

@ -173,7 +173,7 @@ class Stylizer(object):
return (None, None)
data = hrefs[path].data
data = XHTML_CSS_NAMESPACE + data
return (None, data)
return ('utf-8', data)
def flatten_rule(self, rule, href, index):
results = []

View File

@ -840,7 +840,9 @@ def _readUrl(url, fetcher=None, overrideEncoding=None, parentEncoding=None):
try:
# encoding may still be wrong if encoding *is lying*!
if content is not None:
if isinstance(content, unicode):
decodedCssText = content
elif content is not None:
decodedCssText = codecs.lookup("css")[1](content, encoding=encoding)[0]
else:
decodedCssText = None