Wednesday, May 18, 2016

Re: com.google.gwt.http.client.URL

I think you should be % encoding the url data-path components. Any routine that converts spaces to + or leaves '*' and most other punctuation unescaped is not what you want.

See http://stackoverflow.com/a/6530792/1341731 for a "drop-in" routine to do this.

I would remove the "Locale.US" parameter for GWT and just use "toUpperCase()".

On 05/18/2016 10:08 AM, P.G.Taboada wrote:
Hi Thomas, 

I do not want to complain - I am stating an issue I am having - and I find the naming misleading. 

I have to build an URL for a http request - key-value pairs in the query string. 

As far as I understood, application/x-www-form-urlencoded does not apply to "simple GET queries" - am I wrong?

brgds,

Papick


Am Mittwoch, 18. Mai 2016 15:50:57 UTC+2 schrieb Thomas Broyer:
I'm sorry I don't get what you're actually complaining about.
http://www.gwtproject.org/javadoc/latest/com/google/gwt/http/client/URL.html
Only the deprecated methods have that note in their javadoc, and the behavior was historically meant for query-string processing (for the majority of cases where the query-string uses key-value pairs with an encoding similar to application/x-www-form-urlencoded, as with HTML forms with method="GET"), non-deprecated methods are clear about their intent and expected usage: encodeQueryString vs. encodePathSegment.
See also https://github.com/gwtproject/gwt/issues/3379

On Wednesday, May 18, 2016 at 2:30:24 PM UTC+2, P.G.Taboada wrote:
Hi,


we are running into issues with URLs that get spaces encoded to "+". 


In the javadocs I read:


Note: this method will convert any the space character into 
its escape short form, '+' rather than %20. 
It should therefore only be used for query-string parts.


This is wrong: the "+" means a space only in application/x-www-form-urlencoded content.

The method that allows us to use the correct behaviour


public static String encodeComponent( String decodedURLComponent,  boolean queryStringSpaces)


is deprecated.

The make it a "+" behaviour is the default one in the UrlEncoder in Java. This class is either wrongly named or does the wrong thing.  I would guess it is wrongly named, as the javadocs state that this class is for form encoding.


--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment