guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Path: (web uri) - split-and-decode-uri-path must preserve plus character


From: Brent
Subject: Path: (web uri) - split-and-decode-uri-path must preserve plus characters
Date: Thu, 17 Jul 2014 07:24:46 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

Hi all,

Attached is a patch to to correct the behaviour of split-and-decode-uri-path in uri.scm from guile 2.0.9.

Fault
-------
The faulty behaviour is:

    (use-modules (web uri))
(split-and-decode-uri-path "xxx/abc+def/yyy") → ("xxx" "abc def" "yyy")

As can be seen, the plus has been erroneously converted to a space.

The correct behaviour is:

(split-and-decode-uri-path "xxx/abc+def/yyy") → ("xxx" "abc+def" "yyy")

Analysis
------------
The fault is actually in the uri-decode function invoked by split-and-decode-uri-path:
it has special logic to check for a #\+ character and convert it to a space.

The reason for this is that uri-decode is also used to decode query string for application/x-www-form-urlencoded requests where spaces are encoded by the client
on submission to plus characters.

(see http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1)

Fix
---
The fix is to extend uri-decode with a new keyword argument #:form? that is defaulted
to #t. This provides backward compatibility.

split-and-decode-uri-path is modified to call uri-decode with #:form? set to #f.

Motivation
---------------
This patch is motivated by the need to embed ISO 8601 timestamps with time zones
into URLs:

eg. GET http:/foo.org/aaa/bbb/20140717T072233+0200/xxx/yyy


Please consider this for inclusion.


Thanks,

Brent

Attachment: fix-web-uri-decode-plus-to-space.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]