summaryrefslogtreecommitdiff
path: root/tests/buf
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-09-25 10:48:19 -0400
committerEdward Thomson <ethomson@github.com>2016-05-26 13:01:07 -0500
commit8cb27223b8eda4767179a1f226f96d2bdec2fe44 (patch)
tree3c0d776eaa465e7f875b02c27eed56fa01170ad8 /tests/buf
parent0267c34c0cbcdd3b5935d5988d572564dbe5d939 (diff)
downloadlibgit2-8cb27223b8eda4767179a1f226f96d2bdec2fe44.tar.gz
git_buf_quote/unquote: handle > \177
Parse values up to and including `\377` (`0xff`) when unquoting. Print octal values as an unsigned char when quoting, lest `printf` think we're talking about negatives.
Diffstat (limited to 'tests/buf')
-rw-r--r--tests/buf/quote.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/buf/quote.c b/tests/buf/quote.c
index ed5021e25..6f77ab9c1 100644
--- a/tests/buf/quote.c
+++ b/tests/buf/quote.c
@@ -25,6 +25,7 @@ void test_buf_quote__quote_succeeds(void)
expect_quote_pass("\"foo\\r\\nbar\"", "foo\r\nbar");
expect_quote_pass("\"foo\\177bar\"", "foo\177bar");
expect_quote_pass("\"foo\\001bar\"", "foo\001bar");
+ expect_quote_pass("\"foo\\377bar\"", "foo\377bar");
}
static void expect_unquote_pass(const char *expected, const char *quoted)
@@ -64,6 +65,7 @@ void test_buf_quote__unquote_succeeds(void)
expect_unquote_pass("foo\r\nbar", "\"foo\\015\\012bar\"");
expect_unquote_pass("foo\r\nbar", "\"\\146\\157\\157\\015\\012\\142\\141\\162\"");
expect_unquote_pass("newline: \n", "\"newline: \\012\"");
+ expect_unquote_pass("0xff: \377", "\"0xff: \\377\"");
}
void test_buf_quote__unquote_fails(void)
@@ -76,6 +78,9 @@ void test_buf_quote__unquote_fails(void)
expect_unquote_fail("\"invalid escape char \\p\"");
expect_unquote_fail("\"invalid \\1 escape char \"");
expect_unquote_fail("\"invalid \\14 escape char \"");
+ expect_unquote_fail("\"invalid \\280 escape char\"");
+ expect_unquote_fail("\"invalid \\378 escape char\"");
+ expect_unquote_fail("\"invalid \\380 escape char\"");
expect_unquote_fail("\"invalid \\411 escape char\"");
expect_unquote_fail("\"truncated escape char \\\"");
expect_unquote_fail("\"truncated escape char \\0\"");