]> granicus.if.org Git - jq/commitdiff
Fixed base64 issue with UTF-8 strings
authorWilliam Langford <wlangfor@gmail.com>
Tue, 1 Jul 2014 17:17:48 +0000 (13:17 -0400)
committerNicolas Williams <nico@cryptonector.com>
Wed, 2 Jul 2014 03:56:13 +0000 (22:56 -0500)
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
builtin.c
tests/all.test

index 8a809f51523ca49e613de61bbd813d11620f1971..6a1d7961c240792d1fe19810aac833dfb1d6f9d7 100644 (file)
--- a/builtin.c
+++ b/builtin.c
@@ -454,7 +454,7 @@ static jv f_format(jv input, jv fmt) {
     input = f_tostring(input);
     jv line = jv_string("");
     const char b64[64 + 1] = CHARS_ALPHANUM "+/";
-    const char* data = jv_string_value(input);
+    const unsigned char* data = (const unsigned char*)jv_string_value(input);
     int len = jv_string_length_bytes(jv_copy(input));
     for (int i=0; i<len; i+=3) {
       uint32_t code = 0;
index 171c8087eaad957158f8632fd86666e4c42505b5..3b52ec904d650eb37d1a7e1ec8c11c09f4cbb200 100644 (file)
@@ -71,6 +71,11 @@ null
 "'<>&'\\''\"'"
 "PD4mJyI="
 
+# regression test for #436
+@base64
+"foĆ³bar\n"
+"Zm/Ds2Jhcgo="
+
 @uri
 "\u03bc"
 "%CE%BC"