From 8850d5f21535b206f53af93baed02ad31366f993 Mon Sep 17 00:00:00 2001 From: tdro Date: Tue, 22 Nov 2022 11:49:41 -0500 Subject: themes/default/layouts/partials/function-content: Ungreedy and avoid regex injection Whoops, simplify block quote fixer with lazy regex search and avoid injection with standard replace --- themes/default/layouts/partials/function-content.html | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/themes/default/layouts/partials/function-content.html b/themes/default/layouts/partials/function-content.html index 239badc..9ad5a1a 100644 --- a/themes/default/layouts/partials/function-content.html +++ b/themes/default/layouts/partials/function-content.html @@ -10,22 +10,14 @@ replaceRE "

" "" | -}} -{{- $blockquoteFooters := findRE `\n

(–|—).*

` .Content -}} -{{- range $blockquoteFooter := $blockquoteFooters -}} - {{- $blockquoteFooterFixed := $blockquoteFooter | - replaceRE "\n

" "

" | - -}} - {{- $content = $content | replaceRE $blockquoteFooter $blockquoteFooterFixed -}} -{{- end -}} +{{- $brokenBlockquotes := findRE `(?sU)\n

(–|—).*

` .Content -}} -{{- $blockquoteFooters = findRE `(?s)\n

(–|—).*

` .Content -}} -{{- range $blockquoteFooter := $blockquoteFooters -}} - {{- $blockquoteFooterFixed := $blockquoteFooter | +{{- range $brokenBlockquote := $brokenBlockquotes -}} + {{- $fixedBlockquote := $brokenBlockquote | replaceRE "\n

" "

" | -}} - {{- $content = $content | replaceRE $blockquoteFooter $blockquoteFooterFixed -}} + {{- $content = replace $content $brokenBlockquote $fixedBlockquote -}} {{- end -}} {{- if $empty -}} -- cgit v1.2.3