diff options
author | Edward Thomson <ethomson@microsoft.com> | 2013-08-20 03:46:26 +0400 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2013-08-20 03:46:26 +0400 |
commit | c0b01b7572232bd6c0cd848e9b92ed8a8d678bcf (patch) | |
tree | 8e553e46bd1608bf596faa629437a5cf371a0c40 /tests-clar/core | |
parent | 5e1fb2828a496d70c5c200b01e2fb0062268f468 (diff) |
Skip UTF-8 BOM in binary detection
When a git_buf contains a UTF-8 BOM, the three bytes comprising
that BOM are treated as unprintable characters. For a small git_buf,
the three BOM characters overwhelm the printable characters. This
is problematic when trying to check out a small file as the CR/LF
filtering will not apply.
Diffstat (limited to 'tests-clar/core')
-rw-r--r-- | tests-clar/core/buffer.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests-clar/core/buffer.c b/tests-clar/core/buffer.c index 9d9628cfd..8a0b6711f 100644 --- a/tests-clar/core/buffer.c +++ b/tests-clar/core/buffer.c @@ -718,6 +718,8 @@ void test_core_buffer__classify_with_utf8(void) size_t data1len = 31; char *data2 = "Internal NUL!!!\000\n\nI see you!\n"; size_t data2len = 29; + char *data3 = "\xef\xbb\xbfThis is UTF-8 with a BOM.\n"; + size_t data3len = 20; git_buf b; b.ptr = data0; b.size = b.asize = data0len; @@ -731,6 +733,10 @@ void test_core_buffer__classify_with_utf8(void) b.ptr = data2; b.size = b.asize = data2len; cl_assert(git_buf_text_is_binary(&b)); cl_assert(git_buf_text_contains_nul(&b)); + + b.ptr = data3; b.size = b.asize = data3len; + cl_assert(!git_buf_text_is_binary(&b)); + cl_assert(!git_buf_text_contains_nul(&b)); } #define SIMILARITY_TEST_DATA_1 \ |