1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-19 03:00:25 +02:00

Fix uri-decode behavior for "+"

* module/web/uri.scm (uri-decode): Add #:decode-plus-to-space? keyword
  argument.
  (split-and-decode-uri-path): Don't decode plus to space.
* doc/ref/web.texi (URIs): Update documentation.
* test-suite/tests/web-uri.test ("decode"): Add tests.
* NEWS: Add entry.

Based on a patch by Brent <brent@tomski.co.za>.
This commit is contained in:
Andy Wingo 2016-06-20 14:34:19 +02:00
parent 05b3e0608e
commit 0a3ea0586d
4 changed files with 25 additions and 5 deletions

View file

@ -245,7 +245,7 @@ serialization.
Declare a default port for the given URI scheme.
@end deffn
@deffn {Scheme Procedure} uri-decode str [#:encoding=@code{"utf-8"}]
@deffn {Scheme Procedure} uri-decode str [#:encoding=@code{"utf-8"}] [#:decode-plus-to-space? #t]
Percent-decode the given @var{str}, according to @var{encoding}, which
should be the name of a character encoding.
@ -262,6 +262,11 @@ decoded bytes are not valid for the given encoding. Pass @code{#f} for
@xref{Ports, @code{set-port-encoding!}}, for more information on
character encodings.
If @var{decode-plus-to-space?} is true, which is the default, also
replace instances of the plus character @samp{+} with a space character.
This is needed when parsing @code{application/x-www-form-urlencoded}
data.
Returns a string of the decoded characters, or a bytevector if
@var{encoding} was @code{#f}.
@end deffn