diff options
author | tdro <tdro@noreply.example.com> | 2022-11-22 11:49:41 -0500 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2022-11-22 11:49:41 -0500 |
commit | 8850d5f21535b206f53af93baed02ad31366f993 (patch) | |
tree | e5161dd94b7916eebe17cea74be5b5474be56ab3 /themes | |
parent | 5f42caffdda9a43b7a627d59102478ba564527c4 (diff) | |
download | canory-8850d5f21535b206f53af93baed02ad31366f993.tar.gz canory-8850d5f21535b206f53af93baed02ad31366f993.tar.bz2 canory-8850d5f21535b206f53af93baed02ad31366f993.zip |
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
Diffstat (limited to 'themes')
-rw-r--r-- | themes/default/layouts/partials/function-content.html | 16 |
1 files 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 "</figure></p>" "</figure>" | -}} -{{- $blockquoteFooters := findRE `</blockquote>\n<p>(–|—).*</p>` .Content -}} -{{- range $blockquoteFooter := $blockquoteFooters -}} - {{- $blockquoteFooterFixed := $blockquoteFooter | - replaceRE "</blockquote>\n<p>" "<footer><cite>" | - replaceRE "</p>" "</cite></footer></blockquote>" | - -}} - {{- $content = $content | replaceRE $blockquoteFooter $blockquoteFooterFixed -}} -{{- end -}} +{{- $brokenBlockquotes := findRE `(?sU)</blockquote>\n<p>(–|—).*</p>` .Content -}} -{{- $blockquoteFooters = findRE `(?s)</blockquote>\n<p>(–|—).*</p>` .Content -}} -{{- range $blockquoteFooter := $blockquoteFooters -}} - {{- $blockquoteFooterFixed := $blockquoteFooter | +{{- range $brokenBlockquote := $brokenBlockquotes -}} + {{- $fixedBlockquote := $brokenBlockquote | replaceRE "</blockquote>\n<p>" "<footer><cite>" | replaceRE "</p>" "</cite></footer></blockquote>" | -}} - {{- $content = $content | replaceRE $blockquoteFooter $blockquoteFooterFixed -}} + {{- $content = replace $content $brokenBlockquote $fixedBlockquote -}} {{- end -}} {{- if $empty -}} |