diff --git a/fanficfare/adapters/base_adapter.py b/fanficfare/adapters/base_adapter.py index c90b8295..51647b25 100644 --- a/fanficfare/adapters/base_adapter.py +++ b/fanficfare/adapters/base_adapter.py @@ -670,6 +670,7 @@ try to download.

return url in self.add_img_names def include_css_urls(self,parenturl,style): + FONT_EXTS = ('ttf','otf','woff','woff2') # logger.debug("include_css_urls(%s,%s)"%(parenturl,style)) ## pass in the style string, will be returned with URLs ## replaced and images will be added. @@ -680,12 +681,16 @@ try to download.

## url('href') ## the pattern will also accept mismatched '/", which is broken CSS. for style_url in re.findall(r'url\([\'"]?(.*?)[\'"]?\)', style): - logger.debug("Adding style url(%s)"%style_url) ## additional_images don't get processing. Applies ## only to CSS url(), that should be the only time ## additional_images is used. if self.is_additional_image(style_url): + logger.debug("Skipping sheet style url(%s), in additional_images"%style_url) continue + if style_url.rsplit('.')[-1].lower() in FONT_EXTS: + logger.debug("Skipping sheet style url(%s), assumed font"%style_url) + continue + logger.debug("Adding style url(%s)"%style_url) try: # longdesc(aka origurl) isn't saved anywhere in CSS. diff --git a/fanficfare/epubutils.py b/fanficfare/epubutils.py index 1637ef50..c65bed32 100644 --- a/fanficfare/epubutils.py +++ b/fanficfare/epubutils.py @@ -20,6 +20,8 @@ from .six import ensure_text, text_type as unicode from .six import string_types as basestring from io import BytesIO +FONT_EXTS = ('ttf','otf','woff','woff2') + # from io import StringIO # import cProfile, pstats # from pstats import SortKey @@ -191,6 +193,9 @@ def get_update_data(inputio, for style_url in re.findall(r'url\([\'"]?(.*?)[\'"]?\)', style): if style_url.startswith('failedtoload'): continue + if style_url.rsplit('.')[-1].lower() in FONT_EXTS: + logger.debug("Skipping sheet style url(%s), assumed font"%style_url) + continue logger.debug("Updating inline/embedded style url(%s)"%style_url) newsrc='' longdesc='' @@ -262,6 +267,9 @@ def get_update_data(inputio, # logger.debug("%s CSS url:%s"%(href,style)) ## the pattern will also accept mismatched '/", which is broken CSS. for style_url in re.findall(r'url\([\'"]?(.*?)[\'"]?\)', style): + if style_url.rsplit('.')[-1].lower() in FONT_EXTS: + logger.debug("Skipping sheet style url(%s), assumed font"%style_url) + continue logger.debug("Updating sheet style url(%s)"%style_url) newsrc='' longdesc=''