From 0286df971104de01b6b9193b7324d2c3c9c9cf28 Mon Sep 17 00:00:00 2001 From: Frieder Griesshammer Date: Sun, 9 Oct 2022 19:45:12 +0200 Subject: [PATCH] Fix value shortcode to not access (faulty) variables before checking them --- layouts/shortcodes/value.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/shortcodes/value.html b/layouts/shortcodes/value.html index d9eabc7..8d35d0b 100644 --- a/layouts/shortcodes/value.html +++ b/layouts/shortcodes/value.html @@ -1,12 +1,12 @@ {{- $section := default (.Get 0) (.Get "section") -}} -{{- $key := default (.Get 1) (.Get "key") -}} -{{- $value := index $.Site.Data.values $section $key -}} {{- if not $section }} {{- errorf "missing parameter 'section': %s" .Position }} {{- end }} +{{- $key := default (.Get 1) (.Get "key") -}} {{- if not $key }} {{- errorf "missing parameter 'key': %s" .Position }} {{- end }} +{{- $value := index $.Site.Data.values $section $key }} {{- if not $value }} {{- errorf "missing, empty or null value at 'values/%s.%s': %s" $section $key .Position }} {{- end }}