Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
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.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/t0111-atom.sh | 45 |
1 file changed, 45 insertions, 0 deletions
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 </dev/null) && + printf "tree %s\n" "$tree" >commit && + printf "author Odd & Name \003 \375 \357\277\276 X <odd@example.com> 1112354055 +0200\n" >>commit && + printf "committer C O Mitter <committer@example.com> 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 <tmp >oddfeed && + printf "<subtitle>d < e & ? ? ? \303\251</subtitle>\n" >expect && + grep "^<subtitle>" oddfeed >actual && + test_cmp expect actual && + printf "<title>a < b & c ? ? ? \303\251</title>\n" >expect && + grep "^<title>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 |
