Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

carriage return character causes json misparse #26

Open
psilord opened this issue Dec 7, 2019 · 0 comments
Open

carriage return character causes json misparse #26

psilord opened this issue Dec 7, 2019 · 0 comments

Comments

@psilord
Copy link

psilord commented Dec 7, 2019

Hello,

A literal ^M character in a string will cause jsown to misparse numbers.

In the code below I wrote ^M as explicitly two characters where you could see it, otherwise the
github markup system interpreted it as a carriage return.

CL-USER> (jsown:val-safe (jsown:parse "{ \"weights\" : [ 0.5, 0.5^M ] }") "weights")
(1/2 1/20)

I worked around it by stripping all \r and \n characters from my strings before parsing them, but I figured you'd want to know.

Thank you.

@psilord psilord changed the title carriage return character causes json miparse carriage return character causes json misparse Dec 7, 2019
madnificent added a commit that referenced this issue Feb 5, 2020
The issue of reading with a return character in the string was
mentioned in #26.

This change idea allows for setting the :junk-allowed option when
reading numbers.  This option allows for more freedom then necessary,
but the performance implications seem very minimal.  Although we
should consider alternatives, setting the (unexported)
`jsown::*allow-junk-in-integers-p*` parameter to a truethy value will
allow such reading at the moment.  As we ponder on alternatives a
better solution may be found.

It is currently optional as there might be side-effects and there is
probably a cleaner option.  The current solution allows for random
junk where we should probably only allow whitespace.  Nevertheless,
the solution may help should someone be stuck.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant