gitweb: Handle non UTF-8 text better

gitweb assumes that everything is in UTF-8. If a text contains invalid
UTF-8 character sequences, the text must be in a different encoding.

This commit introduces $fallback_encoding which would be used as input
encoding if gitweb encounters text with is not valid UTF-8.

Add basic test for this in t/t9500-gitweb-standalone-no-errors.sh

Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Tested-by: Alexandre Julliard <julliard@winehq.org>
Tested-by: Ismail Dönmez <ismail@pardus.org.tr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Martin Koegler
2007-06-03 17:42:44 +02:00
committed by Junio C Hamano
parent 2169368fc1
commit 00f429af7b
2 changed files with 59 additions and 10 deletions

View File

@ -487,4 +487,32 @@ test_expect_success \
'gitweb_run "p=.git;a=atom"'
test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
# encoding/decoding
test_expect_success \
'encode(commit): utf8' \
'. ../t3901-utf8.txt &&
echo "UTF-8" >> file &&
git add file &&
git commit -F ../t3900/1-UTF-8.txt &&
gitweb_run "p=.git;a=commit"'
test_debug 'cat gitweb.log'
test_expect_success \
'encode(commit): iso-8859-1' \
'. ../t3901-8859-1.txt &&
echo "ISO-8859-1" >> file &&
git add file &&
git config i18n.commitencoding ISO-8859-1 &&
git commit -F ../t3900/ISO-8859-1.txt &&
git config --unset i18n.commitencoding &&
gitweb_run "p=.git;a=commit"'
test_debug 'cat gitweb.log'
test_expect_success \
'encode(log): utf-8 and iso-8859-1' \
'gitweb_run "p=.git;a=log"'
test_debug 'cat gitweb.log'
test_done