Skip to content

Commit 3a95c96

Browse files
committed
Add safeHTML function on user input text/html
1 parent b202e3b commit 3a95c96

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

layouts/partials/alert.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
{{- $textColor100 := index (dict "default" "text-raven-100" "info" "text-blue-100" "warn" "text-orange-100" "alert" "text-red-100") $type -}}
1616
{{- $textColor700 := index (dict "default" "text-raven-700" "info" "text-blue-700" "warn" "text-orange-700" "alert" "text-red-700") $type -}}
1717
<div class="flex items-center justify-center font-content-sans rounded {{ $bgColor100 }} px-4 py-4" role="alert">
18-
<span class="text-xs font-bold uppercase leading-none rounded-full {{ $textColor100 }} {{ $bgColor500 }} px-2 py-1 mr-3">{{ $badge }}</span>
19-
<span class="font-semibold {{ $textColor700 }}">{{ .message | markdownify }}</span>
18+
<span class="text-xs font-bold uppercase leading-none rounded-full {{ $textColor100 }} {{ $bgColor500 }} px-2 py-1 mr-3">{{ $badge | safeHTML }}</span>
19+
<span class="font-semibold {{ $textColor700 }}">{{ .message | markdownify | safeHTML }}</span>
2020
</div>

layouts/partials/button.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
{{- with $svg }}
2929
{{ . | safeHTML }}
3030
{{- end }}
31-
<span>{{ $text }}</span>
31+
<span>{{ $text | safeHTML }}</span>
3232
</a>
3333
{{- else }}
3434
<button class="{{ $class }}" role="button">
3535
{{- with $svg }}
3636
{{ . | safeHTML }}
3737
{{- end }}
38-
<span>{{ $text }}</span>
38+
<span>{{ $text | safeHTML }}</span>
3939
</button>
4040
{{- end }}

layouts/partials/figure.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@
4646
{{- if or (or (.title) (.caption)) (.attr) }}
4747
<figcaption class="{{ $captionClass }}">
4848
{{- with (.title) }}
49-
<h4>{{ . }}</h4>
49+
<h4>{{ . | safeHTML }}</h4>
5050
{{- end }}
5151
{{- if or (.caption) (.attr) }}
52-
<p>{{- .caption | markdownify -}}
52+
<p>{{- .caption | markdownify | safeHTML -}}
5353
{{ if .attr }} {{ end }}{{/* yup, just a space */}}
5454
{{- with .attrlink }}<a href="{{ . }}">{{- end -}}
55-
{{ .attr | markdownify }}
55+
{{ .attr | markdownify | safeHTML }}
5656
{{- if .attrlink }}</a>{{- end -}}
5757
</p>
5858
{{- end }}

0 commit comments

Comments
 (0)