mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-13 18:40:54 +01:00
Added support for downloading external images in SVG for privacy plugin (#7650)
This commit is contained in:
parent
1357cd26af
commit
7dc96f1e13
@ -313,12 +313,19 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
|
||||
file = self._queue(url, config)
|
||||
el.set("src", resolve(file))
|
||||
|
||||
# Handle external image in SVG
|
||||
if el.tag == "image":
|
||||
url = urlparse(el.get("href"))
|
||||
if not self._is_excluded(url, initiator):
|
||||
file = self._queue(url, config)
|
||||
el.set("href", resolve(file))
|
||||
|
||||
# Return element as string
|
||||
return self._print(el)
|
||||
|
||||
# Find and replace all external asset URLs in current page
|
||||
return re.sub(
|
||||
r"<(?:(?:a|link)[^>]+href|(?:script|img)[^>]+src)=['\"]?http[^>]+>",
|
||||
r"<(?:(?:a|link|image)[^>]+href|(?:script|img)[^>]+src)=['\"]?http[^>]+>",
|
||||
replace, output, flags = re.I | re.M
|
||||
)
|
||||
|
||||
|
@ -313,12 +313,19 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
|
||||
file = self._queue(url, config)
|
||||
el.set("src", resolve(file))
|
||||
|
||||
# Handle external image in SVG
|
||||
if el.tag == "image":
|
||||
url = urlparse(el.get("href"))
|
||||
if not self._is_excluded(url, initiator):
|
||||
file = self._queue(url, config)
|
||||
el.set("href", resolve(file))
|
||||
|
||||
# Return element as string
|
||||
return self._print(el)
|
||||
|
||||
# Find and replace all external asset URLs in current page
|
||||
return re.sub(
|
||||
r"<(?:(?:a|link)[^>]+href|(?:script|img)[^>]+src)=['\"]?http[^>]+>",
|
||||
r"<(?:(?:a|link|image)[^>]+href|(?:script|img)[^>]+src)=['\"]?http[^>]+>",
|
||||
replace, output, flags = re.I | re.M
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user