summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Dolan <mu@netsoc.tcd.ie>2012-12-29 01:37:22 +0000
committerStephen Dolan <mu@netsoc.tcd.ie>2012-12-29 01:37:22 +0000
commit3a5377e183976cc6dafa16a17f608e091dfa96b9 (patch)
treee483976f16de7f1f4e6f0722739910857008cb3a
parent79c9c418c6c6312c550b9253b62701f3f788dfa2 (diff)
Fix a bug in URI-encoding of certain non-ASCII characters.
Oh how I hate C casting rules.
-rw-r--r--builtin.c2
-rw-r--r--testdata4
2 files changed, 5 insertions, 1 deletions
diff --git a/builtin.c b/builtin.c
index de40be7e..bb704bb8 100644
--- 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 {
diff --git a/testdata b/testdata
index 36429f59..50e73203 100644
--- 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>"