]> granicus.if.org Git - jq/commitdiff
Let @uri produce uppercase hexadecimal digits...
authorZhiming Wang <zmwangx@gmail.com>
Mon, 30 Jun 2014 02:48:01 +0000 (19:48 -0700)
committerNicolas Williams <nico@cryptonector.com>
Tue, 1 Jul 2014 00:52:42 +0000 (19:52 -0500)
instead of lowercase ones.

According to RFC 3986,

   The uppercase hexadecimal digits 'A' through 'F' are equivalent to
   the lowercase digits 'a' through 'f', respectively.  If two URIs
   differ only in the case of hexadecimal digits used in percent-encoded
   octets, they are equivalent.  For consistency, URI producers and
   normalizers should use uppercase hexadecimal digits for all percent-
   encodings.

See https://github.com/stedolan/jq/issues/451 for details.

Test suite and manual are also updated to reflect this change.

Signed-off-by: Nicolas Williams <nico@cryptonector.com>
builtin.c
docs/content/3.manual/manual.yml
tests/all.test

index 7b215e61e7cc12aff5bd86b704864f9f93d26441..8a809f51523ca49e613de61bbd813d11620f1971 100644 (file)
--- a/builtin.c
+++ b/builtin.c
@@ -413,7 +413,7 @@ static jv f_format(jv input, jv fmt) {
       if (ch < 128 && unreserved[ch]) {
         line = jv_string_append_buf(line, s, 1);
       } else {
-        line = jv_string_concat(line, jv_string_fmt("%%%02x", ch));
+        line = jv_string_concat(line, jv_string_fmt("%%%02X", ch));
       }
       s++;
     }
index 2e8312992de5d2c238fffe1ea22195a1a6d8a773..b460e959aff890eada2aa74eef036d6c665dee68 100644 (file)
@@ -1350,7 +1350,7 @@ sections:
           * `@uri`:
 
             Applies percent-encoding, by mapping all reserved URI
-            characters to a `%xx` sequence.
+            characters to a `%XX` sequence.
 
           * `@csv`:
 
@@ -1379,7 +1379,7 @@ sections:
           will produce the following output for the input
           `{"search":"what is jq?"}`:
 
-              "http://www.google.com/search?q=what%20is%20jq%3f"
+              "http://www.google.com/search?q=what%20is%20jq%3F"
 
           Note that the slashes, question mark, etc. in the URL are
           not escaped, as they were part of the string literal.
index 0b5b9479fca80f35ea147b6ee98f068174a32bfd..171c8087eaad957158f8632fd86666e4c42505b5 100644 (file)
@@ -67,13 +67,13 @@ null
 "\"<>&'\\\"\""
 "1,\"<>&'\"\"\""
 "&lt;&gt;&amp;&apos;&quot;"
-"%3c%3e%26'%22"
+"%3C%3E%26'%22"
 "'<>&'\\''\"'"
 "PD4mJyI="
 
 @uri
 "\u03bc"
-"%ce%bc"
+"%CE%BC"
 
 @html "<b>\(.)</b>"
 "<script>hax</script>"