From 7ef88cbe067b3c58755c6f7bdc68f5adbfcf6bc0 Mon Sep 17 00:00:00 2001 From: interlope Date: Tue, 2 Jun 2026 12:26:08 +0200 Subject: [PATCH] feat: replace htmlspecialchars with blowdit_text for improved text handling across multiple templates --- php/head.php | 22 +++++++++++----------- php/home.php | 18 +++++++++--------- php/icons.php | 12 ++++++++++++ php/navbar.php | 10 +++++----- php/page.php | 8 ++++---- php/sidebar.php | 6 +++--- 6 files changed, 44 insertions(+), 32 deletions(-) diff --git a/php/head.php b/php/head.php index 6ae22f3..4a75736 100644 --- a/php/head.php +++ b/php/head.php @@ -95,19 +95,19 @@ ?> - - - + + + - + - - + + 'https://schema.org', '@type' => 'BlogPosting', - 'headline' => $page->title(), - 'description' => $ldDescription, + 'headline' => blowdit_plain($page->title()), + 'description' => blowdit_plain($ldDescription), 'image' => $ldImage, 'datePublished' => $ldPublished, 'dateModified' => $ldModified, 'author' => array( '@type' => 'Person', - 'name' => $page->username(), + 'name' => blowdit_plain($page->username()), 'url' => Theme::siteUrl(), ), 'publisher' => array( '@type' => 'Organization', - 'name' => $site->title(), + 'name' => blowdit_plain($site->title()), 'logo' => array( '@type' => 'ImageObject', 'url' => DOMAIN_THEME . 'img/favicon.png', @@ -163,7 +163,7 @@ ?> - + diff --git a/php/home.php b/php/home.php index fd90aff..677e03e 100644 --- a/php/home.php +++ b/php/home.php @@ -7,19 +7,19 @@ ?>
- <?php echo htmlspecialchars($site->title(), ENT_QUOTES, 'UTF-8'); ?> -

title(), ENT_QUOTES, 'UTF-8'); ?>

+ <?php echo blowdit_text($site->title()); ?> +

title()); ?>

slogan()) : ?> -

slogan(), ENT_QUOTES, 'UTF-8'); ?>

+

slogan()); ?>

description()) : ?> -

description(), ENT_QUOTES, 'UTF-8'); ?>

+

description()); ?>

$label) : ?> - - <?php echo htmlspecialchars($label, ENT_QUOTES, 'UTF-8') ?> + + <?php echo blowdit_text($label) ?> @@ -53,7 +53,7 @@
-

title(), ENT_QUOTES, 'UTF-8'); ?>

+

title()); ?>

date(); ?> @@ -69,11 +69,11 @@
- category(), ENT_QUOTES, 'UTF-8'); ?> + category()); ?> $tagName) : ?> - +
diff --git a/php/icons.php b/php/icons.php index d9c7b37..027fded 100644 --- a/php/icons.php +++ b/php/icons.php @@ -34,6 +34,18 @@ if (!function_exists('blowdit_icon')) { . 'stroke-linejoin="round" aria-hidden="true">' . $paths[$name] . ''; } + // Bludit already HTML-escapes titles/names on save (Sanitize::html), so a + // plain htmlspecialchars() in the theme double-encodes ("&" -> "&amp;", + // shown as "&"). blowdit_text() decodes any existing entities first, then + // encodes exactly once — correct whether the value is pre-encoded or raw, and + // always output-safe. blowdit_plain() returns decoded text (for JSON-LD etc.). + function blowdit_plain($s) { + return html_entity_decode((string) $s, ENT_QUOTES, 'UTF-8'); + } + function blowdit_text($s) { + return htmlspecialchars(blowdit_plain($s), ENT_QUOTES, 'UTF-8'); + } + // Theme asset URL with an mtime cache-buster (so edited images/SVGs refetch). function blowdit_asset($rel) { $v = @filemtime(THEME_DIR . $rel); diff --git a/php/navbar.php b/php/navbar.php index 26d020c..4b6c9ad 100644 --- a/php/navbar.php +++ b/php/navbar.php @@ -1,7 +1,7 @@