From 12243dd118906962d5bfcfab8357411d5af46c39 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 13:07:12 -1000 Subject: Check the feed escapes what XML cannot carry Every fixture subject was plain ASCII, so xmllint never met a byte the escaping exists for. git commit rewrites stray bytes as Latin-1 and the commit parser replaces any that are left, so the commit is written by hand and the description carries a stray byte to the feed's own check. --- tests/t0111-atom.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'tests') diff --git a/tests/t0111-atom.sh b/tests/t0111-atom.sh index 3040b79..6d3e2c6 100755 --- a/tests/t0111-atom.sh +++ b/tests/t0111-atom.sh @@ -82,4 +82,49 @@ test_expect_success XMLLINT 'the empty feed is well-formed xml' ' xmllint --noout feed ' +# Markup in a message has to be escaped, and a control byte, a byte that is +# no UTF-8 and the two noncharacters XML forbids each make a reader reject +# the whole feed, so they are replaced. Valid UTF-8 is kept as it is. git +# commit would rewrite the stray bytes as Latin-1, so the object is written +# by hand. A commit has its stray bytes replaced as it is parsed, so the +# description, which comes from the config as it was written, carries one to +# the feed. +test_expect_success 'set up a commit holding what XML cannot carry' ' + test_create_repo repos/odd && + ( + cd repos/odd && + tree=$(git mktree commit && + printf "author Odd & Name \003 \375 \357\277\276 X 1112354055 +0200\n" >>commit && + printf "committer C O Mitter 1112354055 +0200\n\n" >>commit && + printf "a < b & c \001 \377 \357\277\276 \303\251\n\nbody > x & \002 \376 \357\277\277\n" >>commit && + oid=$(git hash-object -t commit -w commit) && + git update-ref HEAD "$oid" && + git cat-file commit HEAD >actual && + test_cmp commit actual + ) && + cgitrc_repo oddrc odd "repo.desc=$(printf "d < e & \004 \374 \357\277\277 \303\251")" +' + +test_expect_success 'the feed escapes markup and replaces what XML forbids' ' + cgit_ok oddrc "url=odd/atom" >tmp && + strip_headers oddfeed && + printf "d < e & ? ? ? \303\251\n" >expect && + grep "^" oddfeed >actual && + test_cmp expect actual && + printf "a < b & c ? ? ? \303\251\n" >expect && + grep "^a " oddfeed >actual && + test_cmp expect actual && + printf "<content type=\047text\047>body > x & ? ? ?\n" >expect && + grep "^<content " oddfeed >actual && + test_cmp expect actual && + printf "<name>Odd & Name ? ? ? X</name>\n" >expect && + grep "^<name>" oddfeed >actual && + test_cmp expect actual +' + +test_expect_success XMLLINT 'that feed is well-formed xml' ' + xmllint --noout oddfeed +' + test_done -- cgit 2.12.1