]> granicus.if.org Git - jq/commitdiff
Fix a bug in URI-encoding of certain non-ASCII characters.
authorStephen Dolan <mu@netsoc.tcd.ie>
Sat, 29 Dec 2012 01:37:22 +0000 (01:37 +0000)
committerStephen Dolan <mu@netsoc.tcd.ie>
Sat, 29 Dec 2012 01:37:22 +0000 (01:37 +0000)
Oh how I hate C casting rules.

builtin.c
testdata

index de40be7e79b8b10d1472af5feafe6f1c273ab529..bb704bb88b09b14b91bde57f0a2c282a6e985b18 100644 (file)
--- a/builtin.c
+++ b/builtin.c
@@ -306,7 +306,7 @@ static jv f_format(jv input, jv fmt) {
     jv line = jv_string("");
     const char* s = jv_string_value(input);
     for (int i=0; i<jv_string_length(jv_copy(input)); i++) {
-      unsigned ch = (unsigned)*s;
+      unsigned ch = (unsigned)(unsigned char)*s;
       if (ch < 128 && unreserved[ch]) {
         line = jv_string_append_buf(line, s, 1);
       } else {
index 36429f59ed158c478e80dc0b07edadc923a0acf1..50e7320398f89f88cb716611afd0e483b5b45cd4 100644 (file)
--- a/testdata
+++ b/testdata
@@ -62,6 +62,10 @@ null
 "'<>&'\\''\"'"
 "PD4mJyI="
 
+@uri
+"\u03bc"
+"%ce%bc"
+
 @html "<b>\(.)</b>"
 "<script>hax</script>"
 "<b>&lt;script&gt;hax&lt;/script&gt;</b>"