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

Numbers with extra prefix 0 should not be accepted as valid input #591

Open
MichaelSuen-thePointer opened this issue May 17, 2023 · 3 comments

Comments

@MichaelSuen-thePointer
Copy link

What did you do?

ujson.loads("0012")

What did you expect to happen?

exception raised, ValueError for example

What actually happened?

function returns 12

What versions are you using?

  • OS: Debian 10
  • Python: 3.7.3
  • UltraJSON: 5.7.0

Please include code that reproduces the issue.

The best reproductions are self-contained scripts with minimal dependencies.

try:
    ujson.loads("0012")
    print("not ok")
except ValueError:
    print("ok")
@bwoodsend
Copy link
Collaborator

The JSON spec explicitly allows parsers to accept input that isn't part of the spec but whose intention is clear and non ambiguous.

Beyond purism, why does this actually matter?

@MichaelSuen-thePointer
Copy link
Author

The JSON spec explicitly allows parsers to accept input that isn't part of the spec but whose intention is clear and non ambiguous.

Beyond purism, why does this actually matter?

I was porting code from python standard json to ujson for better performance, and the code relies on loads("0012") to fail.

@bwoodsend
Copy link
Collaborator

You're probably better off going with orjson then. They take the opposite stance to us on accepting non standard inputs.

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

2 participants