mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2025-02-20 03:51:12 +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)
|
file = self._queue(url, config)
|
||||||
el.set("src", resolve(file))
|
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 element as string
|
||||||
return self._print(el)
|
return self._print(el)
|
||||||
|
|
||||||
# Find and replace all external asset URLs in current page
|
# Find and replace all external asset URLs in current page
|
||||||
return re.sub(
|
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
|
replace, output, flags = re.I | re.M
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -313,12 +313,19 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
|
|||||||
file = self._queue(url, config)
|
file = self._queue(url, config)
|
||||||
el.set("src", resolve(file))
|
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 element as string
|
||||||
return self._print(el)
|
return self._print(el)
|
||||||
|
|
||||||
# Find and replace all external asset URLs in current page
|
# Find and replace all external asset URLs in current page
|
||||||
return re.sub(
|
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
|
replace, output, flags = re.I | re.M
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user