aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-11-22 11:49:41 -0500
committertdro <tdro@noreply.example.com>2022-11-22 11:49:41 -0500
commit8850d5f21535b206f53af93baed02ad31366f993 (patch)
treee5161dd94b7916eebe17cea74be5b5474be56ab3
parent5f42caffdda9a43b7a627d59102478ba564527c4 (diff)
downloadcanory-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
-rw-r--r--themes/default/layouts/partials/function-content.html16
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>(&ndash;|&mdash;).*</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>(&ndash;|&mdash;).*</p>` .Content -}}
-{{- $blockquoteFooters = findRE `(?s)</blockquote>\n<p>(&ndash;|&mdash;).*</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 -}}