From af4671f917e4d9d346fcbc7295dcc91d38872a70 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Wed, 14 May 2025 15:45:24 +0200 Subject: [PATCH] FIX improve sanitization of chapter index titles and anchors to allow dashes in addition to alphanumeric characters --- includes/utilities.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/utilities.php b/includes/utilities.php index 49e090d..9dd694f 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -196,8 +196,8 @@ function build_page_chapter_index($blocks) if ($block['blockName'] == 'homegrade-content-blocks/content-heading' && isset($block['attrs']['title']) && isset($block['attrs']['headingLevel']) && $block['attrs']['headingLevel'] == "h2") { array_push($chapterBlockIndex, [ 'block-type' => $block['blockName'], - 'anchor' => "#" . preg_replace('/[^a-zA-Z0-9]/', '', strip_tags($block['attrs']['idName'])), // remove html tags all non-alphanumeric characters - 'title' => preg_replace('/[^a-zA-Z0-9\s]/', '', strip_tags($block['attrs']['title'])), // remove html tags all non-alphanumeric characters + 'anchor' => "#" . preg_replace('/[^a-zA-Z0-9-]/', '', strip_tags($block['attrs']['idName'])), // remove html tags all non-alphanumeric characters except dashes + 'title' => preg_replace('/[^a-zA-Z0-9\s-]/', '', strip_tags($block['attrs']['title'])), // remove html tags all non-alphanumeric characters except dashes ]); } if ($block['blockName'] == 'homegrade-content-blocks/chapitrage-thematique') {