1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

Fix uri-encoding for octets 0-15

* module/web/uri.scm (uri-encode): All encoded octets should be of the
  form % HEXDIGIT HEXDIGIT.
* test-suite/tests/web-uri.test ("encode"): Add test.
This commit is contained in:
Ian Price 2012-08-20 23:03:38 +01:00 committed by Ludovic Courtès
parent dc7a9cefbf
commit b401fe7169
2 changed files with 4 additions and 1 deletions

View file

@ -377,6 +377,8 @@ the byte."
(if (< i len)
(let ((byte (bytevector-u8-ref bv i)))
(display #\% port)
(when (< byte 16)
(display #\0 port))
(display (number->string byte 16) port)
(lp (1+ i))))))))
str)))

View file

@ -258,4 +258,5 @@
(equal? "foo bar" (uri-decode "foo+bar"))))
(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"))))