From 968fbe1ae213cb350850cfddf2614a1c93e73adb Mon Sep 17 00:00:00 2001 From: squidfunk Date: Mon, 16 Dec 2024 11:16:09 +0100 Subject: [PATCH] Fixed privacy plugin interop with generated files --- material/plugins/privacy/plugin.py | 5 +++++ src/plugins/privacy/plugin.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/material/plugins/privacy/plugin.py b/material/plugins/privacy/plugin.py index aba2b8b29..b13ced8bb 100644 --- a/material/plugins/privacy/plugin.py +++ b/material/plugins/privacy/plugin.py @@ -268,6 +268,11 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]): if extension not in self.assets_expr_map: return [] + # Skip if source path is not set, which might be true for generated + # files or for files that were added programatically in plugins + if not initiator.abs_src_path: + return [] + # Find and extract all external asset URLs expr = re.compile(self.assets_expr_map[extension], flags = re.I | re.M) with open(initiator.abs_src_path, encoding = "utf-8-sig") as f: diff --git a/src/plugins/privacy/plugin.py b/src/plugins/privacy/plugin.py index aba2b8b29..b13ced8bb 100644 --- a/src/plugins/privacy/plugin.py +++ b/src/plugins/privacy/plugin.py @@ -268,6 +268,11 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]): if extension not in self.assets_expr_map: return [] + # Skip if source path is not set, which might be true for generated + # files or for files that were added programatically in plugins + if not initiator.abs_src_path: + return [] + # Find and extract all external asset URLs expr = re.compile(self.assets_expr_map[extension], flags = re.I | re.M) with open(initiator.abs_src_path, encoding = "utf-8-sig") as f: