summaryrefslogtreecommitdiff
path: root/tools/copland/tests/org-renderer.sh
diff options
context:
space:
mode:
authorcashmere <cashmere@autistici.org>2026-09-04 09:05:24 +0200
committercashmere <cashmere@autistici.org>2026-09-04 09:05:24 +0200
commit4f49b16079b27d7ce633619e4cddfdf2bffbc952 (patch)
treec296c1e7f3c3e2f6859c6d3a1b1b208779b89679 /tools/copland/tests/org-renderer.sh
downloadrelic-master.tar.gz
initial commitHEADmaster
Diffstat (limited to 'tools/copland/tests/org-renderer.sh')
-rwxr-xr-xtools/copland/tests/org-renderer.sh30
1 files changed, 30 insertions, 0 deletions
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 '<script|<img[^>]*onerror|href="javascript:' "$output_dir"/*.html; then
+ printf 'Unsafe active HTML escaped into Org renderer output.\n' >&2
+ exit 1
+fi
+if ! rg -q '&lt;script&gt;|&lt;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'