Fixed privacy plugin not picking up protocol-relative URLs

This commit is contained in:
squidfunk
2025-12-18 10:42:37 +01:00
parent 61cad249b6
commit 79ba428abe
2 changed files with 14 additions and 0 deletions

View File

@@ -479,6 +479,13 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
if not os.path.isfile(file.abs_src_path) or not self.config.cache:
path = file.abs_src_path
# In case the URL is a protocol-relative URL that starts with `//`,
# we prepend `http:` as a scheme, assuming that all external assets
# are available via HTTP. If we'd require `https:`, some external
# assets might not be fetchable.
if file.url.startswith("//"):
file.url = f"http:{file.url}"
# Download external asset
log.info(f"Downloading external file: {file.url}")
try:

View File

@@ -479,6 +479,13 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
if not os.path.isfile(file.abs_src_path) or not self.config.cache:
path = file.abs_src_path
# In case the URL is a protocol-relative URL that starts with `//`,
# we prepend `http:` as a scheme, assuming that all external assets
# are available via HTTP. If we'd require `https:`, some external
# assets might not be fetchable.
if file.url.startswith("//"):
file.url = f"http:{file.url}"
# Download external asset
log.info(f"Downloading external file: {file.url}")
try: