[jira] [Commented] (FELIX-5555) JSONParser is not handling escape char properly

2017-02-23 Thread David Bosschaert (JIRA)

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

David Bosschaert commented on FELIX-:
-

I can take a look at fixing this soon if nobody else beats me to it...

> JSONParser is not handling escape char properly
> ---
>
> Key: FELIX-
> URL: https://issues.apache.org/jira/browse/FELIX-
> Project: Felix
>  Issue Type: Bug
>  Components: Utils
>Affects Versions: utils-1.9.0
>Reporter: Chetan Mehrotra
> Fix For: utils-1.9.2
>
>
> {{JSONWriter}} currently adds an escape char for '/'. So "foo=/bar" is 
> rendered as 
> {noformat}
> {"foo":"\/bar"}
> {noformat}
> When such a json is read via {{JSONParser}} then the '\' is not removed
> Following test fails
> {code}
> @Test
> public void escapeChar() throws Exception{
> StringWriter sw = new StringWriter();
> JSONWriter js = new JSONWriter(sw);
> js.object().key("foo").value("/bar").endObject().flush();
> 
> JSONParser jp = new JSONParser(sw.toString());
> assertEquals("/bar", jp.getParsed().get("foo"));
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (FELIX-5555) JSONParser is not handling escape char properly

2017-02-20 Thread Julian Reschke (JIRA)

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

Julian Reschke commented on FELIX-:
---

Indeed, see :

{noformat}
   string = quotation-mark *char quotation-mark

   char = unescaped /
   escape (
   %x22 /  ; "quotation mark  U+0022
   %x5C /  ; \reverse solidus U+005C
   %x2F /  ; /solidus U+002F
   %x62 /  ; bbackspace   U+0008
   %x66 /  ; fform feed   U+000C
   %x6E /  ; nline feed   U+000A
   %x72 /  ; rcarriage return U+000D
   %x74 /  ; ttab U+0009
   %x75 4HEXDIG )  ; uU+

   escape = %x5C  ; \

   quotation-mark = %x22  ; "

   unescaped = %x20-21 / %x23-5B / %x5D-10
{noformat}

> JSONParser is not handling escape char properly
> ---
>
> Key: FELIX-
> URL: https://issues.apache.org/jira/browse/FELIX-
> Project: Felix
>  Issue Type: Bug
>  Components: Utils
>Affects Versions: utils-1.9.0
>Reporter: Chetan Mehrotra
> Fix For: utils-1.9.2
>
>
> {{JSONWriter}} currently adds an escape char for '/'. So "foo=/bar" is 
> rendered as 
> {noformat}
> {"foo":"\/bar"}
> {noformat}
> When such a json is read via {{JSONParser}} then the '\' is not removed
> Following test fails
> {code}
> @Test
> public void escapeChar() throws Exception{
> StringWriter sw = new StringWriter();
> JSONWriter js = new JSONWriter(sw);
> js.object().key("foo").value("/bar").endObject().flush();
> 
> JSONParser jp = new JSONParser(sw.toString());
> assertEquals("/bar", jp.getParsed().get("foo"));
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (FELIX-5555) JSONParser is not handling escape char properly

2017-02-20 Thread Chetan Mehrotra (JIRA)

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

Chetan Mehrotra commented on FELIX-:


bq. escaping of the writer is correct, a slash can be espaced - it's not a must 
though

http://stackoverflow.com/questions/1580647/json-why-are-forward-slashes-escaped 
also confirms that. FWIW org.json.JSONObject did not escaped the slash but its 
done by other libraries

> JSONParser is not handling escape char properly
> ---
>
> Key: FELIX-
> URL: https://issues.apache.org/jira/browse/FELIX-
> Project: Felix
>  Issue Type: Bug
>  Components: Utils
>Affects Versions: utils-1.9.0
>Reporter: Chetan Mehrotra
> Fix For: utils-1.9.2
>
>
> {{JSONWriter}} currently adds an escape char for '/'. So "foo=/bar" is 
> rendered as 
> {noformat}
> {"foo":"\/bar"}
> {noformat}
> When such a json is read via {{JSONParser}} then the '\' is not removed
> Following test fails
> {code}
> @Test
> public void escapeChar() throws Exception{
> StringWriter sw = new StringWriter();
> JSONWriter js = new JSONWriter(sw);
> js.object().key("foo").value("/bar").endObject().flush();
> 
> JSONParser jp = new JSONParser(sw.toString());
> assertEquals("/bar", jp.getParsed().get("foo"));
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (FELIX-5555) JSONParser is not handling escape char properly

2017-02-20 Thread Carsten Ziegeler (JIRA)

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

Carsten Ziegeler commented on FELIX-:
-

The escaping of the writer is correct, a slash can be espaced - it's not a must 
though - some libs do, others don't. So I think this needs to be handled in the 
parser

> JSONParser is not handling escape char properly
> ---
>
> Key: FELIX-
> URL: https://issues.apache.org/jira/browse/FELIX-
> Project: Felix
>  Issue Type: Bug
>  Components: Utils
>Affects Versions: utils-1.9.0
>Reporter: Chetan Mehrotra
> Fix For: utils-1.9.2
>
>
> {{JSONWriter}} currently adds an escape char for '/'. So "foo=/bar" is 
> rendered as 
> {noformat}
> {"foo":"\/bar"}
> {noformat}
> When such a json is read via {{JSONParser}} then the '\' is not removed
> Following test fails
> {code}
> @Test
> public void escapeChar() throws Exception{
> StringWriter sw = new StringWriter();
> JSONWriter js = new JSONWriter(sw);
> js.object().key("foo").value("/bar").endObject().flush();
> 
> JSONParser jp = new JSONParser(sw.toString());
> assertEquals("/bar", jp.getParsed().get("foo"));
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (FELIX-5555) JSONParser is not handling escape char properly

2017-02-20 Thread Chetan Mehrotra (JIRA)

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

Chetan Mehrotra commented on FELIX-:


Added ignored test in 1783740. 

> JSONParser is not handling escape char properly
> ---
>
> Key: FELIX-
> URL: https://issues.apache.org/jira/browse/FELIX-
> Project: Felix
>  Issue Type: Bug
>  Components: Utils
>Affects Versions: utils-1.9.0
>Reporter: Chetan Mehrotra
> Fix For: utils-1.9.2
>
>
> {{JSONWriter}} currently adds an escape char for '/'. So "foo=/bar" is 
> rendered as 
> {noformat}
> {"foo":"\/bar"}
> {noformat}
> When such a json is read via {{JSONParser}} then the '\' is not removed
> Following test fails
> {code}
> @Test
> public void escapeChar() throws Exception{
> StringWriter sw = new StringWriter();
> JSONWriter js = new JSONWriter(sw);
> js.object().key("foo").value("/bar").endObject().flush();
> 
> JSONParser jp = new JSONParser(sw.toString());
> assertEquals("/bar", jp.getParsed().get("foo"));
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)