Skip to content

fix: correct ~1 decode in decode_pointer_inplace()#1001

Open
SummerSolsticeMuch wants to merge 1 commit intoDaveGamble:masterfrom
SummerSolsticeMuch:fix/decode-pointer-tilde1
Open

fix: correct ~1 decode in decode_pointer_inplace()#1001
SummerSolsticeMuch wants to merge 1 commit intoDaveGamble:masterfrom
SummerSolsticeMuch:fix/decode-pointer-tilde1

Conversation

@SummerSolsticeMuch
Copy link
Copy Markdown

Summary

  • Fix off-by-one in decode_pointer_inplace() where ~1 writes to decoded_string[1] instead of decoded_string[0]

The ~0 case correctly writes to decoded_string[0], but the ~1 case writes to decoded_string[1] — a copy-paste bug. This causes all JSON Pointer / JSON Patch operations on keys containing / (encoded as ~1 per RFC 6901) to silently fail or target the wrong key.

Test plan

  • Apply a JSON Patch with path /a~1b to an object with key a/b — should succeed (currently returns error 13)
  • Verify ~0 decoding still works correctly

The ~1 escape sequence (RFC 6901 Section 4) should decode to '/'.
The ~0 case correctly writes to decoded_string[0], but the ~1 case
writes to decoded_string[1] instead of decoded_string[0]. This is
a copy-paste bug from the ~0 case where only the character was
changed but the index was also accidentally changed.

This causes all JSON Pointer and JSON Patch operations on keys
containing '/' to silently fail or target the wrong key.
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

Successfully merging this pull request may close these issues.

1 participant