Skip to content

substr index calculation does not match JavaScript implementation #12

Description

@panzi

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions