mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 19:50:24 +02:00
web: uri-encode hexadecimal percent-encoding is now uppercase
* module/web/uri.scm (uri-encode): the hexadecimal percent-encoding %HH is now uppercased as suggested by RFC3986: "For consistency, URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings." * test-suite/tests/web-uri.test ("encode"): update tests.
This commit is contained in:
parent
e006d87ba5
commit
6fe2803b45
2 changed files with 8 additions and 7 deletions
|
@ -382,7 +382,7 @@ The default character set includes alphanumerics from ASCII, as well as
|
||||||
the special characters ‘-’, ‘.’, ‘_’, and ‘~’. Any other character will
|
the special characters ‘-’, ‘.’, ‘_’, and ‘~’. Any other character will
|
||||||
be percent-encoded, by writing out the character to a bytevector within
|
be percent-encoded, by writing out the character to a bytevector within
|
||||||
the given ENCODING, then encoding each byte as ‘%HH’, where HH is the
|
the given ENCODING, then encoding each byte as ‘%HH’, where HH is the
|
||||||
hexadecimal representation of the byte."
|
uppercase hexadecimal representation of the byte."
|
||||||
(define (needs-escaped? ch)
|
(define (needs-escaped? ch)
|
||||||
(not (char-set-contains? unescaped-chars ch)))
|
(not (char-set-contains? unescaped-chars ch)))
|
||||||
(if (string-index str needs-escaped?)
|
(if (string-index str needs-escaped?)
|
||||||
|
@ -400,7 +400,8 @@ hexadecimal representation of the byte."
|
||||||
(display #\% port)
|
(display #\% port)
|
||||||
(when (< byte 16)
|
(when (< byte 16)
|
||||||
(display #\0 port))
|
(display #\0 port))
|
||||||
(display (number->string byte 16) port)
|
(display (string-upcase (number->string byte 16))
|
||||||
|
port)
|
||||||
(lp (1+ i))))))))
|
(lp (1+ i))))))))
|
||||||
str)))
|
str)))
|
||||||
str))
|
str))
|
||||||
|
|
|
@ -259,5 +259,5 @@
|
||||||
|
|
||||||
(with-test-prefix "encode"
|
(with-test-prefix "encode"
|
||||||
(pass-if (equal? "foo%20bar" (uri-encode "foo bar")))
|
(pass-if (equal? "foo%20bar" (uri-encode "foo bar")))
|
||||||
(pass-if (equal? "foo%0a%00bar" (uri-encode "foo\n\x00bar")))
|
(pass-if (equal? "foo%0A%00bar" (uri-encode "foo\n\x00bar")))
|
||||||
(pass-if (equal? "%3c%3e%5c%5e" (uri-encode "<>\\^"))))
|
(pass-if (equal? "%3C%3E%5C%5E" (uri-encode "<>\\^"))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue