[ 
https://issues.apache.org/jira/browse/THRIFT-885?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12904872#action_12904872
 ] 

Jordan commented on THRIFT-885:
-------------------------------

Do we even need to call encodeURIComponent in thrift.js? 
>From what I understand, encodeURIComponent is primarily for ensuring one thing 
>- That key value pairs encoded in urls don't get messed up by user supplied 
>text.
Since this is sent over post, in json format, it shouldn't matter right? 
Can't we just skip the uriEncoding step? 

> Url encoded strings never get decoded? How do we fix this?
> ----------------------------------------------------------
>
>                 Key: THRIFT-885
>                 URL: https://issues.apache.org/jira/browse/THRIFT-885
>             Project: Thrift
>          Issue Type: Bug
>            Reporter: Jordan
>
> This is for the test java server that was written to test the client. 
> Suppose you have a method such as          testString(theTestString)
> If you call it from the javascript like so:
> client.testString("hello man");
> The string that your server implementation sees will be all crazy and url 
> encoded.
> public static void testString(string theTestString) {
>    // Inside here that string looks like "hello%20man".
> }
> We need it to be urlencoded when coming across the wire because we're using 
> JSON as the protocol, but once it gets to thrift server code, it needs to be 
> normal.
> So what's going on here? Inside of strings (of javascript objects) things 
> like quotes and spaces are escaped. This is fine, but I do not believe that 
> is part of the TJSONProtocol. This is something that is specific to having a 
> js thrift client am I right? So where do we fix this?
> I'm not exactly sure what will work, but the following seemed to work mostly 
> okay, but there are still bugs. I basically just strip out encoded parts from 
> the entire message (even though the problem seems to only exist inside string 
> fields.)
> Around line 115.
> <code>
>                 HttpEntity entity = ((HttpEntityEnclosingRequest) 
> request).getEntity();
>                 byte[] entityContent = EntityUtils.toByteArray(entity);
>                               String decodedEntityContentString = 
> java.net.URLDecoder.decodeURIComponent(new String(entityContent, "UTF-8"));
>                               byte[] decodedEntityContentBytes = 
> decodedEntityContentString.getBytes("UTF-8");
>                               System.out.println("Incoming content: " + new 
> String(entityContent));
>                               System.out.println("Incoming content 
> normalized: " + new String(decodedEntityContentBytes, "UTF-8"));
>                 
>                               // This almost works, except escaped quotes 
> inside of strings
>                                      final String output = 
> this.thriftRequest(decodedEntityContentBytes);
>                               System.out.println("Outgoing content: "+output);
>                 
>                               EntityTemplate body = new EntityTemplate(new 
> ContentProducer() {
> </code>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to