[bug-yhg8dqypwmar] fix(check-naming): reject media fallback provenance #6

Closed
architect wants to merge 1 commits from architect/bug-yhg8dqypwmar/reject-rendered-fallback-provenance into main
3 changed files with 31 additions and 13 deletions
Showing only changes of commit 4b91be68a2 - Show all commits
+21 -13
View File
@@ -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 ~ /^<details([[:space:]>])/) {
opening=lower
sub(/^</, "", opening)
sub(/[[:space:]>].*$/, "", 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
}
}
')
+4
View File
@@ -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 "<h2>Tracking</h2>"
else if (line ~ /^## Attribution[[:space:]]*$/) print "<h2>Attribution</h2>"
else if (line ~ /^- Fixes[[:space:]]/) print "<li>" substr(line, 3) "</li>"
+6
View File
@@ -188,6 +188,12 @@ check_contract "open details inside collapsed details remain hidden" \
check_contract "open text in another details attribute remains collapsed" \
$'<details title="x open y"><summary>Release notes</summary>\n\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n</details>' \
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
check_contract "video fallback cannot hide provenance" \
$'<video controls>\n\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n</video>' \
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
check_contract "audio fallback cannot hide provenance" \
$'<audio controls>\n\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n</audio>' \
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
check_contract_pass "unrelated collapsed details remain available" \
$'<details><summary>Logs</summary>\n\nSupporting output\n</details>\n\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>' \
"$BASE" "$GOOD_HEAD"