summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 13f8b72)
raw | patch | inline | side by side (parent: 13f8b72)
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | |
Thu, 15 Dec 2011 13:47:23 +0000 (20:47 +0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 15 Dec 2011 19:35:10 +0000 (11:35 -0800) |
Current implementation sees NUL as terminator. If users give a message
with NUL byte in it (e.g. editor set to save as UTF-16), the new commit
message will have NULs. However following operations (displaying or
amending a commit for example) will not keep anything after the first NUL.
Stop user right when they do this. If NUL is added by mistake, they have
their chance to fix. Otherwise, log messages will no longer be text "git
log" and friends would grok.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
with NUL byte in it (e.g. editor set to save as UTF-16), the new commit
message will have NULs. However following operations (displaying or
amending a commit for example) will not keep anything after the first NUL.
Stop user right when they do this. If NUL is added by mistake, they have
their chance to fix. Otherwise, log messages will no longer be text "git
log" and friends would grok.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit.c | patch | blob | history | |
t/t3900-i18n-commit.sh | patch | blob | history |
diff --git a/commit.c b/commit.c
index 0a214a649e1b3d5011e14a3dc227753f2bd2be05..80e61b4cf551a05b06f5944018265868767515bf 100644 (file)
--- a/commit.c
+++ b/commit.c
assert_sha1_type(tree, OBJ_TREE);
+ if (memchr(msg->buf, '\0', msg->len))
+ return error("a NUL byte in commit log message not allowed.");
+
/* Not having i18n.commitencoding is the same as having utf-8 */
encoding_is_utf8 = is_encoding_utf8(git_commit_encoding);
diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh
index 1f62c151b0aa63b4c85f9bc76f501d53967b0260..d48a7c002d622ffac5087be9a7998f781a242731 100755 (executable)
--- a/t/t3900-i18n-commit.sh
+++ b/t/t3900-i18n-commit.sh
test z = "z$E"
'
+test_expect_failure 'UTF-16 refused because of NULs' '
+ echo UTF-16 >F &&
+ git commit -a -F "$TEST_DIRECTORY"/t3900/UTF-16.txt
+'
+
+
for H in ISO8859-1 eucJP ISO-2022-JP
do
test_expect_success "$H setup" '