summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Langford <wlangfor@gmail.com>2014-07-01 13:17:48 -0400
committerNicolas Williams <nico@cryptonector.com>2014-07-01 22:56:13 -0500
commit9f4d7e2fb85951ec93e4ee1b99072d5517658db5 (patch)
tree344bbf4614feea28869775d418a7e04b7400fca8
parentba1acbe961789c099d6116ea2b2164bc09dd5339 (diff)
Fixed base64 issue with UTF-8 strings
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
-rw-r--r--builtin.c2
-rw-r--r--tests/all.test5
2 files changed, 6 insertions, 1 deletions
diff --git a/builtin.c b/builtin.c
index 8a809f51..6a1d7961 100644
--- 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;
diff --git a/tests/all.test b/tests/all.test
index 171c8087..3b52ec90 100644
--- a/tests/all.test
+++ b/tests/all.test
@@ -71,6 +71,11 @@ null
"'<>&'\\''\"'"
"PD4mJyI="
+# regression test for #436
+@base64
+"foĆ³bar\n"
+"Zm/Ds2Jhcgo="
+
@uri
"\u03bc"
"%CE%BC"