Subsetting embedded fonts: Fix an error when subsetting embedded fonts on windows if the username contains quotes or apostrophes. Fixes #1316533 [subset all embedded fonts > colect_font_stats error](https://bugs.launchpad.net/calibre/+bug/1316533)

This commit is contained in:
Kovid Goyal 2014-05-07 08:27:33 +05:30
parent 1294718845
commit 418cb87f13

View File

@ -253,6 +253,10 @@ class StatsCollector(object):
src = rule.get('src', None) src = rule.get('src', None)
if not src: if not src:
continue continue
if src.startswith('url(') and src.endswith(')') and src[4] not in {'"', "'"}:
# Quote the url otherwise cssutils fails to parse it if it has
# ' or " in it
src = "url('" + src[4:-1].replace("'", "\\'") + "')"
style = self.parser.parseStyle('background-image:%s'%src, validate=False) style = self.parser.parseStyle('background-image:%s'%src, validate=False)
src = style.getProperty('background-image').propertyValue[0].uri src = style.getProperty('background-image').propertyValue[0].uri
name = self.href_to_name(src, '@font-face rule') name = self.href_to_name(src, '@font-face rule')