From 4f49b16079b27d7ce633619e4cddfdf2bffbc952 Mon Sep 17 00:00:00 2001 From: cashmere Date: Fri, 4 Sep 2026 09:05:24 +0200 Subject: initial commit --- tools/copland/tests/org-renderer.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 tools/copland/tests/org-renderer.sh (limited to 'tools/copland/tests/org-renderer.sh') diff --git a/tools/copland/tests/org-renderer.sh b/tools/copland/tests/org-renderer.sh new file mode 100755 index 0000000..1822d52 --- /dev/null +++ b/tools/copland/tests/org-renderer.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +set -euo pipefail + +root_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +source "$root_dir/scripts/fossil-env.sh" +fixture_dir="$root_dir/tests/fixtures/org" +output_dir=$(mktemp -d -t copland-org-renderer.XXXXXX) + +for fixture in all security; do + "$FOSSIL" test-org-render "$fixture_dir/$fixture.org" >"$output_dir/$fixture.html" + diff -u "$fixture_dir/$fixture.html" "$output_dir/$fixture.html" +done + +"$FOSSIL" test-org-render --text "$fixture_dir/all.org" >"$output_dir/all.txt" +diff -u "$fixture_dir/all.txt" "$output_dir/all.txt" + +sed 's/$/\r/' "$fixture_dir/all.org" >"$output_dir/all-crlf.org" +"$FOSSIL" test-org-render "$output_dir/all-crlf.org" >"$output_dir/all-crlf.html" +diff -u "$fixture_dir/all.html" "$output_dir/all-crlf.html" + +if rg -n ']*onerror|href="javascript:' "$output_dir"/*.html; then + printf 'Unsafe active HTML escaped into Org renderer output.\n' >&2 + exit 1 +fi +if ! rg -q '<script>|<img' "$output_dir/security.html"; then + printf 'Escaped security fixture content is missing.\n' >&2 + exit 1 +fi + +printf 'Org renderer golden and security tests passed.\n' -- cgit v1.3.1