Matt Feury <
matt...@gmail.com> writes:
> Howdy Hi Hello,
>
> We ran into an interesting issue on our servers tonight, involving the
> dreaded u\2028 character. After some research, I learned something new: There
> are some characters that are valid javascript but not valid json, including
> U+2028 <
http://timelessrepo.com/json-isnt-a-javascript-subset>.
>
> Essentially, someone inserted some data to our db with one of these
> characters, and once we send this down as json (a JObject), the client
> throws an 'Unexpected Token ILLEGAL' error. As the above link describes,
> this is character is not valid json.
>
> Now, I could easily escape these characters on my end, but I wonder if it
> isn't a better idea to have lift-json handle this case. It would avoid a
> lot of potential complications, methinks. Antonio recommended a potential
> solution being to have a toggle on the implicit formats value, but I would
> go so far as to say, since 'lift-json' handles json, it should *always*
> escape these characters since they are invalid json.
Actually, it's a valid JSON character, but an invalid Javascript
character.
It's only when you convert the JSON to use as javascript in the browser
that you'll see this issue.
One other option would be for lift to escape when writing a
JsonResponse. But this would then also escape when writing a pure
rest-service.
/Jeppe