Import normalizer: offline tool to normalize the raw archive spreadsheets #663
@@ -72,10 +72,15 @@ jobs:
|
|||||||
# Svelte default escaping, never {@html}. This guard flags any {@html ...}
|
# Svelte default escaping, never {@html}. This guard flags any {@html ...}
|
||||||
# whose expression references a raw-date variable. A comment mentioning
|
# whose expression references a raw-date variable. A comment mentioning
|
||||||
# "{@html}" without a raw token inside the braces does NOT match.
|
# "{@html}" without a raw token inside the braces does NOT match.
|
||||||
pattern='\{@html[^}]*(metaDateRaw|documentDateRaw|rawDate)'
|
# The token list MUST cover every variable that carries the raw value:
|
||||||
# Self-test: the regex must catch the dangerous form and ignore the comment form.
|
# DocumentDate.svelte exposes it via the `raw` prop, so `\braw\b` is included.
|
||||||
|
# Grow this list whenever a new raw-bearing variable name is introduced.
|
||||||
|
pattern='\{@html[^}]*(metaDateRaw|documentDateRaw|rawDate|\braw\b)'
|
||||||
|
# Self-test: the regex must catch the dangerous forms and ignore the comment form.
|
||||||
printf '{@html doc.metaDateRaw}\n' | grep -qP "$pattern" \
|
printf '{@html doc.metaDateRaw}\n' | grep -qP "$pattern" \
|
||||||
|| { echo "FAIL: guard self-test — regex missed the unsafe {@html metaDateRaw} form"; exit 1; }
|
|| { echo "FAIL: guard self-test — regex missed the unsafe {@html metaDateRaw} form"; exit 1; }
|
||||||
|
printf '{@html raw}\n' | grep -qP "$pattern" \
|
||||||
|
|| { echo "FAIL: guard self-test — regex missed the unsafe {@html raw} form (DocumentDate prop)"; exit 1; }
|
||||||
printf 'never use {@html} for this\n' | grep -qvP "$pattern" \
|
printf 'never use {@html} for this\n' | grep -qvP "$pattern" \
|
||||||
|| { echo "FAIL: guard self-test — regex wrongly flagged a {@html} comment"; exit 1; }
|
|| { echo "FAIL: guard self-test — regex wrongly flagged a {@html} comment"; exit 1; }
|
||||||
if grep -rPln "$pattern" --include='*.svelte' frontend/src/; then
|
if grep -rPln "$pattern" --include='*.svelte' frontend/src/; then
|
||||||
|
|||||||
Reference in New Issue
Block a user