Skip to content

Commit

Permalink
Handle external images for SVGs in privacy plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
nejch committed Oct 29, 2024
1 parent 1357cd2 commit cf63558
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/plugins/privacy/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,19 @@ def replace(match: Match):
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
)

Expand Down

0 comments on commit cf63558

Please sign in to comment.