mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
Fix uri-encoding for strings with no unreserved chars
* module/web/uri.scm (uri-encode): Change test to check for unreserved chars instead of reserved chars. * test-suite/tests/web-uri.test ("encode"): Add test.
This commit is contained in:
parent
b401fe7169
commit
866210bf24
2 changed files with 5 additions and 2 deletions
|
@ -364,7 +364,9 @@ Percent-encoding first writes out the given character to a bytevector
|
|||
within the given @var{encoding}, then encodes each byte as
|
||||
@code{%@var{HH}}, where @var{HH} is the hexadecimal representation of
|
||||
the byte."
|
||||
(if (string-index str unescaped-chars)
|
||||
(define (needs-escaped? ch)
|
||||
(not (char-set-contains? unescaped-chars ch)))
|
||||
(if (string-index str needs-escaped?)
|
||||
(call-with-output-string*
|
||||
(lambda (port)
|
||||
(string-for-each
|
||||
|
|
|
@ -259,4 +259,5 @@
|
|||
|
||||
(with-test-prefix "encode"
|
||||
(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 "<>\\^"))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue