Repository navigation
fix(parser): use byte offsets instead of char indices in extract_json_object - #2751
Conversation
KuSh
left a comment
There was a problem hiding this comment.
Hi, thanks for your PR. It contains an unrelated change that should be withdrawn; otherwise, LGTM
There was a problem hiding this comment.
This change seems unrelated to the PR’s subject
ea9507a to
b8a5919
Compare
…_object extract_json_object() used char indices from enumerate() as byte offsets when slicing the input string. For multi-byte UTF-8 characters (CJK, emoji), this causes a 'not a char boundary' panic because char index != byte offset. Switch from Vec<char> + enumerate() to char_indices() which yields correct byte offsets. Add regression tests for CJK values, emoji values, CJK prefixes, and mixed multi-byte nested JSON. Fixes rtk-ai#2509
b8a5919 to
b1b7de5
Compare
|
Heyaaa : ) This benchmark test hits httpbin.org/robots.txt live and compares raw vs filtered token counts. I think that the difference is may be due to varying response headers/content from httpbin.org between runs? The changes in this PR only touch registry.rs (rewrite logic) and main.rs , so no curl filter code was modified. |
|
httpbin.org seems a bit erratic; it can take 20+ seconds to respond or even return a 503. That said, this PR should stay focused on a single subject. Also, you’ve added two new commits (191c8f8 and 566f856) that don’t seem related to the PR’s topic. Please revert them, if this is a real issue that needs fixing, could you please open a separate PR with this two commits, a clear description of the problem and the fix? |
566f856 to
27f9739
Compare
|
Oh thanks for the heads up and review ! The clippy CI failure is a pre-existing issue on develop — uv_cmd.rs:61 calls print_with_hint with 4 args but the signature expects 5 (missing guard_raw). |
Summary
extract_json_object()used char indices fromenumerate()as byte offsets for string slicing'not a char boundary'panicVec<char>+enumerate()tochar_indices()which yields correct byte offsetsFixes #2509
Test plan
cargo fmt --all && cargo clippy --all-targets && cargo test --allpasses (2 pre-existing failures inrewrite_cmdunrelated to this change)