hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1195) URIBuilder-created query strings are double-escaped
Date Mon, 25 Jun 2012 09:44:43 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13400379#comment-13400379

Sebb commented on HTTPCLIENT-1195:

I've been looking into the space escaping issue a bit more. 
It's true that space should be escaped %20 in URLs according to RFC 2396 and RFC 3986 (which
obsoletes it).

However SPACE <=> '+' escaping is used for application/x-www-form-urlencoded  [1]
This says it applies for both POST and GET.

I have tested IE, Fx, Chrome and Opera and they all use '+' to escape space when submitting
a form using POST or GET.
They also all use %20 to escape space within the path. For sample form, see [2]

This seems like it might contradict the RFCs, however in 3986 the query part is allowed to
contain '+' without escaping.

So I think the issue here is that different escaping is used for URIs and for form data (which
may be embedded as an URI query)

It seems to me that the parameter format/parse should use space <=> '+' whereas URI
encode/decode needs to use space <=> %20

[Perhaps also need to consider using escape/unescape in method names rather then encode/unencode
to distinguish it from character set encoding.]

[1] http://www.w3.org/TR/html401/interact/forms.html#h-
[2] http://people.apache.org/~sebb/postget.html
> URIBuilder-created query strings are double-escaped
> ---------------------------------------------------
>                 Key: HTTPCLIENT-1195
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1195
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.2 Final
>         Environment: java version "1.6.0_24"
> OpenJDK Runtime Environment (IcedTea6 1.11.1) (6b24-1.11.1-4ubuntu3)
> OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
>            Reporter: Chris K. Jester-Young
>             Fix For: 4.2.1
>         Attachments: HTTPCLIENT-1195-2.patch, HTTPCLIENT-1195.patch
> When setting parameters in URIBuilder, the keys and values are double-escaped: once in
URIBuilder.build(), and again in URI.appendSchemeSpecificPart(). Example:
>     URIBuilder ub = new URIBuilder("http://www.google.com/");
>     ub.addParameter("foo=bar", "baz&qux");
>     ub.build();   // http://www.google.com/?foo%253Dbar=baz%2526qux
> In order to avoid this problem, URIBuilder.build() should use URI's one-argument constructor,
which does not try to do extra escaping.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org

View raw message