Skip to content

Commit

Permalink
fix: fix parser incorrectly escaping labels
Browse files Browse the repository at this point in the history
Added reliability proptests for query parsers and updated the docs for the grammar.

Ref: #51
  • Loading branch information
V0ldek authored Apr 10, 2023
1 parent 837a387 commit 4dab392
Show file tree
Hide file tree
Showing 9 changed files with 466 additions and 62 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"owo_colors",
"Peekable",
"proptest",
"proptests",
"regs",
"repr",
"rsonpath",
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

All notable changes to this project will be documented in this file.

## Unreleased

### Bug fixes

- Fix parser incorrectly escaping labels.
- Queries like `$['\'']` would cause a parsing error, even though they were valid (match a child with key equal to "`'`").
- The `\u` escape sequence is no longer recognized, since without UTF-8 handling they were meaningless.
See ([#117](https://github.com/V0ldek/rsonpath/issues/117)).

### Documentation

- The grammar in top-level documentation now matches the implementation.

### Reliability

- Added proptests for query parsing.

## [0.3.3] - 2023-03-29

### Bug Fixes
Expand Down
10 changes: 5 additions & 5 deletions crates/rsonpath-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@
//! single quoted label = { UNESCAPED | ESCAPED | '"' | "\'" }
//! double quoted label = { UNESCAPED | ESCAPED | "'" | '\"' }
//!
//! ALPHA = ? [A-Z][a-z] ?
//! ALPHANUMERIC = ? [A-Z][a-z][0-9] ?
//! NONASCII = ? UTF8 characters outside of U+0000-U+007F ?
//! UNESCAPED = ? [^'"] ?
//! ESCAPED = ? [btnfru/\\] ?
//! ALPHA = ? [A-Za-z] ?
//! ALPHANUMERIC = ? [A-Za-z0-9] ?
//! NONASCII = ? [\u0080-\u10FFFF] ?
//! UNESCAPED = ? [^'"\u0000-\u001F] ?
//! ESCAPED = ? \\[btnfr/\\] ?
//! ```
//!
//! ## Semantics
Expand Down
4 changes: 2 additions & 2 deletions crates/rsonpath-lib/src/query/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub enum ParserError {
}

/// Error report created during the parser's run over a single input string.
#[derive(Debug)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct ParseErrorReport {
errors: Vec<ParseError>,
}
Expand All @@ -81,7 +81,7 @@ impl Display for ParseErrorReport {

/// Single error raised during parsing, defined as the
/// contiguous sequence of characters that caused the error.
#[derive(Debug)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct ParseError {
/// The index at which the error occurred.
pub start_idx: usize,
Expand Down
Loading

0 comments on commit 4dab392

Please sign in to comment.