From 4b91be68a27a536fd6af41666f39d3df4f797b44 Mon Sep 17 00:00:00 2001 From: Evelyn Chen Date: Thu, 27 Aug 2026 18:02:22 +0000 Subject: [PATCH] fix(check-naming): reject media fallback provenance Authored-By: Codex (GPT-5) --- check.sh | 34 +++++++++++++++++++++------------- tests/bin/curl | 4 ++++ tests/run | 6 ++++++ 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/check.sh b/check.sh index f6355fa..95b21f3 100755 --- a/check.sh +++ b/check.sh @@ -41,9 +41,9 @@ elif ! RENDERED_BODY=$(printf '%s' "${BODY}" | FAILED=1 fi -# A collapsed disclosure is valid supporting content, but provenance inside one -# is not visible by default. Remove only collapsed details subtrees; an open -# disclosure remains visible unless one of its ancestors is collapsed. +# Remove rendered subtrees that aren't visible by default. An open disclosure +# remains visible unless one of its ancestors is hidden; media fallback content +# is hidden when the browser supports the containing element. VISIBLE_BODY=$(printf '%s\n' "${RENDERED_BODY}" | awk ' { @@ -54,20 +54,28 @@ VISIBLE_BODY=$(printf '%s\n' "${RENDERED_BODY}" | tag=tag char if (char == ">") { lower=tolower(tag) - if (lower ~ /^])/) { + opening=lower + sub(/^].*$/, "", opening) + closing=lower + sub(/^<\//, "", closing) + sub(/[[:space:]>].*$/, "", closing) + if (opening ~ /^(details|audio|video|canvas|object)$/) { attributes=lower gsub(/"[^"]*"/, "", attributes) - parent_hidden=(details_depth > 0 && hidden[details_depth]) - details_depth++ - hidden[details_depth]=(parent_hidden || attributes !~ /[[:space:]]open([[:space:]=>]|$)/) + parent_hidden=(container_depth > 0 && hidden[container_depth]) + container_depth++ + container[container_depth]=opening + hidden[container_depth]=(parent_hidden || opening != "details" || attributes !~ /[[:space:]]open([[:space:]=>]|$)/) } - else if (lower ~ /^<\/details([[:space:]>])/) { - if (details_depth > 0) { - delete hidden[details_depth] - details_depth-- + else if (closing ~ /^(details|audio|video|canvas|object)$/) { + if (container_depth > 0 && container[container_depth] == closing) { + delete container[container_depth] + delete hidden[container_depth] + container_depth-- } } - else if (!hidden[details_depth]) printf "%s", tag + else if (!hidden[container_depth]) printf "%s", tag in_tag=0 tag="" } @@ -76,7 +84,7 @@ VISIBLE_BODY=$(printf '%s\n' "${RENDERED_BODY}" | in_tag=1 tag=char } - else if (!hidden[details_depth]) printf "%s", char + else if (!hidden[container_depth]) printf "%s", char } } ') diff --git a/tests/bin/curl b/tests/bin/curl index 3832ec0..378904d 100755 --- a/tests/bin/curl +++ b/tests/bin/curl @@ -68,6 +68,10 @@ printf '%s\n' "${PR_BODY}" | awk ' print line next } + if (lower ~ /^[ ]{0,3}<\/?(audio|video|canvas|object)([[:blank:]>])/) { + print line + next + } if (line ~ /^## Tracking[[:space:]]*$/) print "

Tracking

" else if (line ~ /^## Attribution[[:space:]]*$/) print "

Attribution

" else if (line ~ /^- Fixes[[:space:]]/) print "
  • " substr(line, 3) "
  • " diff --git a/tests/run b/tests/run index c6bce89..2fe7909 100755 --- a/tests/run +++ b/tests/run @@ -188,6 +188,12 @@ check_contract "open details inside collapsed details remain hidden" \ check_contract "open text in another details attribute remains collapsed" \ $'
    Release notes\n\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) \n
    ' \ "$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section" +check_contract "video fallback cannot hide provenance" \ + $'' \ + "$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section" +check_contract "audio fallback cannot hide provenance" \ + $'' \ + "$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section" check_contract_pass "unrelated collapsed details remain available" \ $'
    Logs\n\nSupporting output\n
    \n\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) ' \ "$BASE" "$GOOD_HEAD"