[ 
https://issues.apache.org/jira/browse/JENA-884?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andy Seaborne reassigned JENA-884:
----------------------------------

    Assignee: Andy Seaborne

> URI encoding in Params.httpString() and elsewhere
> -------------------------------------------------
>
>                 Key: JENA-884
>                 URL: https://issues.apache.org/jira/browse/JENA-884
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: ARQ
>    Affects Versions: Jena 2.11.0
>            Reporter: Martynas Jusevičius
>            Assignee: Andy Seaborne
>
> I have some code that adds query parameters to SPARQL Protocol requests.
> According to my quick research, the final HTTP query string depends on
> {{com.hp.hpl.jena.sparql.engine.http.Params.httpString()}}:
> {code}
>     public String httpString()
>     {
>         StringBuffer sbuff = new StringBuffer() ;
>         boolean first = true ;
>         for (Pair p : pairs())
>         {
>             if ( !first )
>                 sbuff.append('&') ;
>             sbuff.append(p.getName()) ;
>             sbuff.append('=') ;
>             String x = p.getValue() ;
>             x = Convert.encWWWForm(x) ;
>             sbuff.append(x) ;
>             first = false ;
>         }
>         return sbuff.toString() ;
>     }
> {code}
> I see the parameter values being encoded, but not the names, for some
> reason? Looks like a bug to me.
> Also, the code depends on {{URLEncoder.encode()}}, which implements
> {{application/x-www-form-urlencoded}}, aka HTML form encoding.
> To my understanding, this is different from the URI syntax spec:
> https://tools.ietf.org/html/rfc3986
> One of the differences is space encoded as {{+}} vs. {{%20}}.
> Am I right that the incorrect encoding is used here (and probably in
> similar places)?
> I would suggest using a uniform URI builder in such cases, like this one:
> http://docs.oracle.com/javaee/6/api/javax/ws/rs/core/UriBuilder.html



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to