mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-23 23:21:00 +01:00
Added support for quoted external CSS URLs in privacy plugin (#7651)
This commit is contained in:
parent
7dc96f1e13
commit
4918a10d8f
@ -64,8 +64,8 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
|
|||||||
# Initialize collections of external assets
|
# Initialize collections of external assets
|
||||||
self.assets = Files([])
|
self.assets = Files([])
|
||||||
self.assets_expr_map = {
|
self.assets_expr_map = {
|
||||||
".css": r"url\((\s*http?[^)]+)\)",
|
".css": r"url\(\s*([\"']?)(?P<url>http?[^)'\"]+)\1\s*\)",
|
||||||
".js": r"[\"'](http[^\"']+\.(?:css|js(?:on)?))[\"']",
|
".js": r"[\"'](?P<url>http[^\"']+\.(?:css|js(?:on)?))[\"']",
|
||||||
**self.config.assets_expr_map
|
**self.config.assets_expr_map
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +271,8 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
|
|||||||
# Find and extract all external asset URLs
|
# Find and extract all external asset URLs
|
||||||
expr = re.compile(self.assets_expr_map[extension], flags = re.I | re.M)
|
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:
|
with open(initiator.abs_src_path, encoding = "utf-8-sig") as f:
|
||||||
return [urlparse(url) for url in re.findall(expr, f.read())]
|
results = re.finditer(expr, f.read())
|
||||||
|
return [urlparse(result.group("url")) for result in results]
|
||||||
|
|
||||||
# Parse template or page HTML and find all external links that need to be
|
# Parse template or page HTML and find all external links that need to be
|
||||||
# replaced. Many of the assets should already be downloaded earlier, i.e.,
|
# replaced. Many of the assets should already be downloaded earlier, i.e.,
|
||||||
|
@ -64,8 +64,8 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
|
|||||||
# Initialize collections of external assets
|
# Initialize collections of external assets
|
||||||
self.assets = Files([])
|
self.assets = Files([])
|
||||||
self.assets_expr_map = {
|
self.assets_expr_map = {
|
||||||
".css": r"url\((\s*http?[^)]+)\)",
|
".css": r"url\(\s*([\"']?)(?P<url>http?[^)'\"]+)\1\s*\)",
|
||||||
".js": r"[\"'](http[^\"']+\.(?:css|js(?:on)?))[\"']",
|
".js": r"[\"'](?P<url>http[^\"']+\.(?:css|js(?:on)?))[\"']",
|
||||||
**self.config.assets_expr_map
|
**self.config.assets_expr_map
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +271,8 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
|
|||||||
# Find and extract all external asset URLs
|
# Find and extract all external asset URLs
|
||||||
expr = re.compile(self.assets_expr_map[extension], flags = re.I | re.M)
|
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:
|
with open(initiator.abs_src_path, encoding = "utf-8-sig") as f:
|
||||||
return [urlparse(url) for url in re.findall(expr, f.read())]
|
results = re.finditer(expr, f.read())
|
||||||
|
return [urlparse(result.group("url")) for result in results]
|
||||||
|
|
||||||
# Parse template or page HTML and find all external links that need to be
|
# Parse template or page HTML and find all external links that need to be
|
||||||
# replaced. Many of the assets should already be downloaded earlier, i.e.,
|
# replaced. Many of the assets should already be downloaded earlier, i.e.,
|
||||||
|
Loading…
Reference in New Issue
Block a user