Skip to content

Commit b655e07

Browse files
committed
Fixed HTML entities not escaped in social cards
1 parent 67f1752 commit b655e07

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Diff for: material/plugins/social/plugin.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
from collections import defaultdict
4444
from hashlib import md5
45+
from html import unescape
4546
from io import BytesIO
4647
from mkdocs.commands.build import DuplicateFilter
4748
from mkdocs.exceptions import PluginError
@@ -298,8 +299,9 @@ def _render_text(self, size, font, text, lmax, spacing = 0):
298299
width = size[0]
299300
lines, words = [], []
300301

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

304306
# Retrieve y-offset of textbox to correct for spacing
305307
yoffset = 0

Diff for: src/plugins/social/plugin.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
from collections import defaultdict
4444
from hashlib import md5
45+
from html import unescape
4546
from io import BytesIO
4647
from mkdocs.commands.build import DuplicateFilter
4748
from mkdocs.exceptions import PluginError
@@ -298,8 +299,9 @@ def _render_text(self, size, font, text, lmax, spacing = 0):
298299
width = size[0]
299300
lines, words = [], []
300301

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

304306
# Retrieve y-offset of textbox to correct for spacing
305307
yoffset = 0

0 commit comments

Comments
 (0)