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

Christopher Schultz edited comment on VELTOOLS-184 at 11/18/22 7:12 PM:
------------------------------------------------------------------------

I'm sorry, but whatever JSON parser you are working with is patently broken.

Quoting [RFC 4627, section 
2.5|https://www.ietf.org/rfc/rfc4627.html#section-2.5]:
{quote}Any character may be escaped.
{quote}
So, breaking when ' is (perhaps unexpectedly) escaped means that {_}the library 
is broken{_}.

 


was (Author: ch...@christopherschultz.net):
I'm sorry, but whatever JSON parser you are working with is patently broken.

Quoting [RFC 4627, section 
2.5|[http://example.com|https://www.ietf.org/rfc/rfc4627.html#section-2.5]]:
{quote}Any character may be escaped.
{quote}
So, breaking when ' is (perhaps unexpectedly) escaped means that {_}the library 
is broken{_}.

 

> EscapeTool: add a json method, or a javascript method with a second parameter
> -----------------------------------------------------------------------------
>
>                 Key: VELTOOLS-184
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-184
>             Project: Velocity Tools
>          Issue Type: Improvement
>          Components: GenericTools
>    Affects Versions: 2.x
>         Environment: any
>            Reporter: Maurice Perry
>            Priority: Minor
>              Labels: EscapeTool, escape, javascript, json
>
> The string returned by EscapeTool.javascript() method is not alway compliant 
> with the JSON syntax. For instance, when the input string contains an 
> apostrophe ', a backslash is inserted before it because there is no way for 
> the method to know if the string is enclosed with single or double quotes. 
> This is not compliant with the JSON syntax, and some JSON parsers will reject 
> the string.
> There may be other differences between javascript and JSON strings, but this 
> is the one I encountered, and I had to use a workaround.
> This issue can be solved either with a JSON method, or with a second 
> javascript method with a second parameter indicating the type of quote used.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org

Reply via email to