commit: reject invalid UTF-8 codepoints
The commit code already contains code for validating UTF-8, but it does not check for invalid values, such as guaranteed non-characters and surrogates. Fix this by explicitly checking for and rejecting such characters. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
81a199bb1c
commit
28110d4bfc
@ -39,6 +39,14 @@ test_expect_failure 'UTF-16 refused because of NULs' '
|
||||
git commit -a -F "$TEST_DIRECTORY"/t3900/UTF-16.txt
|
||||
'
|
||||
|
||||
test_expect_success 'UTF-8 invalid characters refused' '
|
||||
test_when_finished "rm -f $HOME/stderr $HOME/invalid" &&
|
||||
echo "UTF-8 characters" >F &&
|
||||
printf "Commit message\n\nInvalid surrogate:\355\240\200\n" \
|
||||
>"$HOME/invalid" &&
|
||||
git commit -a -F "$HOME/invalid" 2>"$HOME"/stderr &&
|
||||
grep "did not conform" "$HOME"/stderr
|
||||
'
|
||||
|
||||
for H in ISO8859-1 eucJP ISO-2022-JP
|
||||
do
|
||||
|
Reference in New Issue
Block a user