From b655e078051dee3980f6c0a67a0eacfe4d534233 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Fri, 20 Sep 2024 09:44:29 +0200 Subject: [PATCH] Fixed HTML entities not escaped in social cards --- material/plugins/social/plugin.py | 4 +++- src/plugins/social/plugin.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/material/plugins/social/plugin.py b/material/plugins/social/plugin.py index edbb91d1d..2e989c156 100644 --- a/material/plugins/social/plugin.py +++ b/material/plugins/social/plugin.py @@ -42,6 +42,7 @@ import sys 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 @@ -298,8 +299,9 @@ class SocialPlugin(BasePlugin[SocialConfig]): 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 diff --git a/src/plugins/social/plugin.py b/src/plugins/social/plugin.py index edbb91d1d..2e989c156 100644 --- a/src/plugins/social/plugin.py +++ b/src/plugins/social/plugin.py @@ -42,6 +42,7 @@ import sys 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 @@ -298,8 +299,9 @@ class SocialPlugin(BasePlugin[SocialConfig]): 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