diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Replace the stray bytes of text that is not UTF-8
A commit whose encoding header names something iconv cannot convert, or whose text is labelled UTF-8 without being it, reached a page declared UTF-8 with its bytes untouched. The atom feed already replaced them, so its UTF-8 reader moves to shared.c and every ident, subject, message and tag text passes through it.
Diffstat (limited to 'tests/t0106-commit.sh')
-rwxr-xr-xtests/t0106-commit.sh19
1 file changed, 19 insertions, 0 deletions
diff --git a/tests/t0106-commit.sh b/tests/t0106-commit.sh
index 39f1822..2b924a0 100755
--- a/tests/t0106-commit.sh
+++ b/tests/t0106-commit.sh
@@ -37,4 +37,23 @@ test_expect_success 'root commit contains diff' '
grep "<div class=.add.>+1</div>" tmp
'
+# A message that is not UTF-8, because its encoding header names something
+# iconv cannot convert or is missing altogether, would otherwise reach a
+# page declared UTF-8 as it is, so its stray bytes become question marks.
+test_expect_success 'a message that is not UTF-8 has its stray bytes replaced' '
+ (
+ cd repos/foo &&
+ tree=$(git rev-parse HEAD^{tree}) &&
+ printf "tree %s\nauthor A U Thor <author@example.com> 1735689600 +0000\n" "$tree" >raw &&
+ printf "committer A U Thor <author@example.com> 1735689600 +0000\n" >>raw &&
+ printf "encoding no-such-charset\n\ncaf\351 subject\n\nbody \377 end\n" >>raw &&
+ cid=$(git hash-object --literally -t commit -w raw) &&
+ git update-ref refs/heads/latin "$cid"
+ ) &&
+ cgit_query "url=foo/commit&h=latin" >tmp &&
+ grep "<div class=.commit-subject.>caf? subject<" tmp &&
+ grep "body ? end" tmp &&
+ ! grep "caf$(printf "\351")" tmp
+'
+
test_done