Fixed privacy plugin not replacing occurrences

This commit is contained in:
squidfunk 2025-03-01 13:22:03 +07:00
parent 3bd81bdc66
commit 523922b383
No known key found for this signature in database
GPG Key ID: 5ED40BC4F9C436DF
2 changed files with 8 additions and 2 deletions

View File

@ -433,7 +433,7 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
# Intercept errors of type `ConnectionError` and `HTTPError`
except Exception as error:
log.warning(f"Couldn't retrieve {file.url}: {error}")
return
return False
# Compute expected file extension and append if missing
mime = res.headers["content-type"].split(";")[0]
@ -484,6 +484,9 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
if not self._is_excluded(url, file):
self._queue(url, config, concurrent = True)
# External asset was successfully downloaded
return True
# Patch all links to external assets in the given file
def _patch(self, initiator: File):
with open(initiator.abs_src_path, encoding = "utf-8-sig") as f:

View File

@ -433,7 +433,7 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
# Intercept errors of type `ConnectionError` and `HTTPError`
except Exception as error:
log.warning(f"Couldn't retrieve {file.url}: {error}")
return
return False
# Compute expected file extension and append if missing
mime = res.headers["content-type"].split(";")[0]
@ -484,6 +484,9 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
if not self._is_excluded(url, file):
self._queue(url, config, concurrent = True)
# External asset was successfully downloaded
return True
# Patch all links to external assets in the given file
def _patch(self, initiator: File):
with open(initiator.abs_src_path, encoding = "utf-8-sig") as f: