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

substr index calculation does not match JavaScript implementation #12

Open
panzi opened this issue Aug 23, 2021 · 1 comment
Open

substr index calculation does not match JavaScript implementation #12

panzi opened this issue Aug 23, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@panzi
Copy link

panzi commented Aug 23, 2021

Just by reviewing the code (haven't actually ran it) I'm pretty sure this library from suffers the same bugs as I've reported to another JsonLogic Rust implementation (except for the type coercion, which seems to be done right here):
Bestowinc/json-logic-rs#27

Long story short: The indices are supposed to operate on UTF-16 surrogate pairs, but in this library they act on full code points, and furthermore String::len() is used at some point which returns the number of bytes as encoded by UTF-8 and as such negative indices on any non-ASCII strings are broken (internally inconsistent).

@marvindv
Copy link
Owner

Thank you for letting me know, I will have a look into it as soon as i can.

@marvindv marvindv added the bug Something isn't working label Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants