Skip to content

Commit

Permalink
Fixed HTML entities not escaped in social cards
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Sep 20, 2024
1 parent 67f1752 commit b655e07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion material/plugins/social/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

from collections import defaultdict
from hashlib import md5
from html import unescape
from io import BytesIO
from mkdocs.commands.build import DuplicateFilter
from mkdocs.exceptions import PluginError
Expand Down Expand Up @@ -298,8 +299,9 @@ def _render_text(self, size, font, text, lmax, spacing = 0):
width = size[0]
lines, words = [], []

# Remove remnant HTML tags
# Remove remnant HTML tags and convert HTML entities
text = re.sub(r"(<[^>]+>)", "", text)
text = unescape(text)

# Retrieve y-offset of textbox to correct for spacing
yoffset = 0
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/social/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

from collections import defaultdict
from hashlib import md5
from html import unescape
from io import BytesIO
from mkdocs.commands.build import DuplicateFilter
from mkdocs.exceptions import PluginError
Expand Down Expand Up @@ -298,8 +299,9 @@ def _render_text(self, size, font, text, lmax, spacing = 0):
width = size[0]
lines, words = [], []

# Remove remnant HTML tags
# Remove remnant HTML tags and convert HTML entities
text = re.sub(r"(<[^>]+>)", "", text)
text = unescape(text)

# Retrieve y-offset of textbox to correct for spacing
yoffset = 0
Expand Down

0 comments on commit b655e07

Please sign in to comment.