You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Gary Gregory <ga...@gmail.com> on 2013/06/05 18:48:56 UTC

[httpclient] URLEncodedUtils parser delimiters

Hi All:

It seems to me that URLEncodedUtils.DELIM should be:

    new char[] { '&', ';' };

instead of:

    new char[] { '&' };

All the tests pass with this change. It just seems like an omission.

Also in
org.apache.http.client.utils.URLEncodedUtils.parse(List<NameValuePair>,
Scanner, String)

    scanner.useDelimiter(PARAMETER_SEPARATOR);

should be:

    scanner.useDelimiter("[&;]");

Am I missing something?

FWIW, I tested with this

    private static final char[] DELIM = new char[] { '&', ';' };
    private static final String DELIM_PATTERN = "[" + new String(DELIM) +
"]";

Gary

-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: [httpclient] URLEncodedUtils parser delimiters

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2013-06-06 at 09:47 -0400, Gary Gregory wrote:
> On Thu, Jun 6, 2013 at 8:25 AM, Oleg Kalnichevski <ol...@apache.org> wrote:
> 
> > On Wed, 2013-06-05 at 12:48 -0400, Gary Gregory wrote:
> > > Hi All:
> > >
> > > It seems to me that URLEncodedUtils.DELIM should be:
> > >
> > >     new char[] { '&', ';' };
> > >
> > > instead of:
> > >
> > >     new char[] { '&' };
> > >
> > > All the tests pass with this change. It just seems like an omission.
> > >
> > >
> > > Also in
> > > org.apache.http.client.utils.URLEncodedUtils.parse(List<NameValuePair>,
> > > Scanner, String)
> > >
> > >     scanner.useDelimiter(PARAMETER_SEPARATOR);
> > >
> > > should be:
> > >
> > >     scanner.useDelimiter("[&;]");
> > >
> > > Am I missing something?
> > >
> >
> >
> > Gary
> >
> > Can you give an example (or better yet, a test case ;-)) of URL encoded
> > content where semicolon is used as a delimiter?
> >
> 
> Hi Oleg,
> 
> See notes 1, 2, and 3 in https://en.wikipedia.org/wiki/URI_scheme
> 
>    1. *^ <https://en.wikipedia.org/wiki/URI_scheme#cite_ref-1>* RFC
> 1866<https://tools.ietf.org/html/rfc1866>section 8.2.1 : by Tim
> Berners-Lee in 1995 encourages CGI authors to
>    support ';' in addition to '&'.
>    2. *^ <https://en.wikipedia.org/wiki/URI_scheme#cite_ref-2>* HTML 4.01
>    Specification: Implementation, and Design
> Notes<http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.2>:
>    "CGI implementors support the use of ";" in place of "&" to save authors
>    the trouble of escaping "&" characters in this manner."
>    3. *^ <https://en.wikipedia.org/wiki/URI_scheme#cite_ref-3>* Hypertext
>    Markup Language -
> 2.0<http://www.w3.org/MarkUp/html-spec/html-spec_foot.html#FOOT26>"CGI
> implementors are encouraged to support the use of ';' in place of '&'
> "
> 
> I use URLEncodedUtils directly in my app to parse URL/URIs.
> 
> I'll add unit tests if these changes are deemed acceptable.
> 
> Gary
> 
> 

I had no idea. Of course, it sounds perfectly reasonable. We should
probably consider changing the formatting routines as well.

Oleg



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


Re: [httpclient] URLEncodedUtils parser delimiters

Posted by Gary Gregory <ga...@gmail.com>.
On Thu, Jun 6, 2013 at 8:25 AM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Wed, 2013-06-05 at 12:48 -0400, Gary Gregory wrote:
> > Hi All:
> >
> > It seems to me that URLEncodedUtils.DELIM should be:
> >
> >     new char[] { '&', ';' };
> >
> > instead of:
> >
> >     new char[] { '&' };
> >
> > All the tests pass with this change. It just seems like an omission.
> >
> >
> > Also in
> > org.apache.http.client.utils.URLEncodedUtils.parse(List<NameValuePair>,
> > Scanner, String)
> >
> >     scanner.useDelimiter(PARAMETER_SEPARATOR);
> >
> > should be:
> >
> >     scanner.useDelimiter("[&;]");
> >
> > Am I missing something?
> >
>
>
> Gary
>
> Can you give an example (or better yet, a test case ;-)) of URL encoded
> content where semicolon is used as a delimiter?
>

Hi Oleg,

See notes 1, 2, and 3 in https://en.wikipedia.org/wiki/URI_scheme

   1. *^ <https://en.wikipedia.org/wiki/URI_scheme#cite_ref-1>* RFC
1866<https://tools.ietf.org/html/rfc1866>section 8.2.1 : by Tim
Berners-Lee in 1995 encourages CGI authors to
   support ';' in addition to '&'.
   2. *^ <https://en.wikipedia.org/wiki/URI_scheme#cite_ref-2>* HTML 4.01
   Specification: Implementation, and Design
Notes<http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.2>:
   "CGI implementors support the use of ";" in place of "&" to save authors
   the trouble of escaping "&" characters in this manner."
   3. *^ <https://en.wikipedia.org/wiki/URI_scheme#cite_ref-3>* Hypertext
   Markup Language -
2.0<http://www.w3.org/MarkUp/html-spec/html-spec_foot.html#FOOT26>"CGI
implementors are encouraged to support the use of ';' in place of '&'
"

I use URLEncodedUtils directly in my app to parse URL/URIs.

I'll add unit tests if these changes are deemed acceptable.

Gary


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


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: [httpclient] URLEncodedUtils parser delimiters

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2013-06-05 at 12:48 -0400, Gary Gregory wrote:
> Hi All:
> 
> It seems to me that URLEncodedUtils.DELIM should be:
> 
>     new char[] { '&', ';' };
> 
> instead of:
> 
>     new char[] { '&' };
> 
> All the tests pass with this change. It just seems like an omission.
> 
>
> Also in
> org.apache.http.client.utils.URLEncodedUtils.parse(List<NameValuePair>,
> Scanner, String)
> 
>     scanner.useDelimiter(PARAMETER_SEPARATOR);
> 
> should be:
> 
>     scanner.useDelimiter("[&;]");
> 
> Am I missing something?
> 


Gary

Can you give an example (or better yet, a test case ;-)) of URL encoded
content where semicolon is used as a delimiter? 

Oleg



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