From b927386173b179d124815e366989da07a711ab3e Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 24 Oct 2026 09:17:41 -1000 Subject: Show characters a browser breaks at as escapes The HTML parser turns a carriage return with no line feed after it into a line feed, and WebKit starts a new line at U+2028 and U+2029, while git and the line numbers count line feeds alone, so each one set every later line of the tree and blame pages a line below its number. CSS Text makes vertical tab, form feed and next line forced breaks as well, though no engine honours that yet. The escapes follow gitweb, which shows control characters the same way. --- tests/t0005-markup.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'tests/t0005-markup.sh') diff --git a/tests/t0005-markup.sh b/tests/t0005-markup.sh index e3cb08d..829c839 100755 --- a/tests/t0005-markup.sh +++ b/tests/t0005-markup.sh @@ -96,15 +96,17 @@ test_expect_success 'the stylesheet and the script name only the current hooks' grep "window.cgit.highlightLines" "$TEST_OUTPUT_DIRECTORY/../assets/cgit.js" ' -# The rest of the hooks need a tag, a symlink, a submodule, a trailer, clone -# urls, an empty repository and a second page of repositories, so they get a -# commit and a config of their own after the checks above have read the first -# ones. +# The rest of the hooks need a tag, a symlink, a submodule, a trailer, a lone +# carriage return, clone urls, an empty repository and a second page of +# repositories, so they get a commit and a config of their own after the checks +# above have read the first ones. test_expect_success 'set up the remaining kinds of entry' ' ( cd repos/hooks && git tag -a -m "first release" v1 && test_ln_s_add file-1 link && + printf "a\\rb\\n" >cr.txt && + git add cr.txt && git update-index --add --cacheinfo "160000,$(git rev-parse HEAD),sub" && git commit -m "more kinds of entry" -m "Fixes: $(git rev-parse --short HEAD)" ) && @@ -139,6 +141,11 @@ test_expect_success 'the refs, summary and tree name every section and row' ' grep "" tmp ' +test_expect_success 'a character the browser would break a line at is an escape' ' + more "hooks/tree/cr.txt" >tmp && + grep "a" tmp +' + test_expect_success 'the commit page has its trailer table and diffstat' ' more "hooks/commit/" >tmp && grep "" tmp && -- cgit 2.9.1