Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed

- Fixed `Token::from_encoded` accepting a `~` immediately followed by
another `~` (e.g. `"~~0"`) as valid, letting safe code build a
`PointerBuf` that `Pointer::parse` then rejected on the same bytes. A `~`
must now always be followed by `0` or `1`. Resolves
[#128](https://github.com/chanced/jsonptr/issues/128).

## [0.8.1] 2026-07-26

### Added
Expand Down
12 changes: 11 additions & 1 deletion src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<'a> Token<'a> {
source: InvalidEncoding::Slash,
})
}
ENC_PREFIX => {
ENC_PREFIX if !escaped => {
escaped = true;
}
TILDE_ENC | SLASH_ENC if escaped => {
Expand Down Expand Up @@ -575,6 +575,16 @@ mod tests {
source: InvalidEncoding::Tilde
}
);
// https://github.com/chanced/jsonptr/issues/128
let err = Token::from_encoded("~~0").unwrap_err();
assert_eq!(
err,
EncodingError {
offset: 1,
source: InvalidEncoding::Tilde
}
);

let sub = String::from("a~");
let err = Token::from_encoded(&sub).unwrap_err();
let labels: Vec<_> = err.labels(&sub).unwrap().collect();
Expand Down
Loading