From 79ba428abebf9b365d4930fb9b147255edd10b88 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Thu, 18 Dec 2025 10:42:37 +0100 Subject: [PATCH] Fixed privacy plugin not picking up protocol-relative URLs --- material/plugins/privacy/plugin.py | 7 +++++++ src/plugins/privacy/plugin.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/material/plugins/privacy/plugin.py b/material/plugins/privacy/plugin.py index eb91f22f0..dae8a9f8d 100644 --- a/material/plugins/privacy/plugin.py +++ b/material/plugins/privacy/plugin.py @@ -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: diff --git a/src/plugins/privacy/plugin.py b/src/plugins/privacy/plugin.py index eb91f22f0..dae8a9f8d 100644 --- a/src/plugins/privacy/plugin.py +++ b/src/plugins/privacy/plugin.py @@ -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: