From 418cb87f13e272dd047803ffe1b1315a77f326d1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 7 May 2014 08:27:33 +0530 Subject: [PATCH] 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) --- src/calibre/ebooks/oeb/polish/stats.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/calibre/ebooks/oeb/polish/stats.py b/src/calibre/ebooks/oeb/polish/stats.py index 77b99ff9b6..948e6aa912 100644 --- a/src/calibre/ebooks/oeb/polish/stats.py +++ b/src/calibre/ebooks/oeb/polish/stats.py @@ -253,6 +253,10 @@ class StatsCollector(object): src = rule.get('src', None) if not src: 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) src = style.getProperty('background-image').propertyValue[0].uri name = self.href_to_name(src, '@font-face rule')