diff --git a/src/calibre/web/fetch/simple.py b/src/calibre/web/fetch/simple.py index 32466e35cf..6a3172efaa 100644 --- a/src/calibre/web/fetch/simple.py +++ b/src/calibre/web/fetch/simple.py @@ -17,6 +17,7 @@ import sys import threading import time import traceback +from base64 import standard_b64decode from urllib.request import urlopen from calibre import browser, relpath, unicode_path @@ -248,13 +249,18 @@ class RecursiveFetcher: ans = response(q) ans.newurl = url return ans - self.log.debug('Fetching', url) st = time.monotonic() + is_data_url = url.startswith('data:') + if not is_data_url: + self.log.debug('Fetching', url) # Check for a URL pointing to the local filesystem and special case it # for efficiency and robustness. Bypasses delay checking as it does not # apply to local fetches. Ensures that unicode paths that are not # representable in the filesystem_encoding work. + if is_data_url: + payload = url.partition(',')[2] + return standard_b64decode(payload) is_local = 0 if url.startswith('file://'): is_local = 7