Repository navigation
fix(config): parse unquoted special-char values in YAML flow collections - #2761
Conversation
Restore the pre-2.4.0 (serde_yaml) tolerance for unquoted flow-collection values that start with a YAML flow indicator (`:`, `>`, `|`), e.g. `triggers: [:->,:>-]`, which PR espanso#2532 (serde_yaml -> serde_norway) broke. serde_norway is libyaml-based and rejects such scalars with "did not find expected node content ... while parsing a flow node". Add a pure `lenient_flow_quote` helper applied only on retry-on-failure: the strict parse is tried first, so every config that parses today is returned byte-for-byte untouched. The fix covers both YAMLMatchGroup and YAMLConfig parse entry points via a shared `parse_lenient<T>` wrapper in `util`. `|`/`>` block-scalar bodies (e.g. a multi-line `replace: |` whose literal text contains `[ ... ]`) are detected and copied verbatim, so the transform never re-quotes inside them. Fixes espanso#2748 Co-Authored-By: Claude <[email protected]>
76516a8 to
73f6098
Compare
|
Updated to fix a defect a post-publish adversarial review found. Before: Now: the transform detects
|
|
Since this one repairs the 2.4.0 flow-collection parsing regression from the serde_norway swap (#2748), I'd appreciate a sanity check on the approach: the config is still parsed strictly first, and the leniently re-quoted retry only runs when that strict parse fails. Would you be open to reviewing it as-is, or is there a different layering or additional regression cases you'd want covered first? I'm glad to prioritise whatever would help it move forward. |
|
Thank you so much! |
Fixes #2748.
Root cause
PR #2532 swapped
serde_yaml0.8 →serde_norway(libyaml-based, strict). A plain (unquoted) scalar inside a flow collection ([...]/{...}) must not begin with a flow-indicator character (:,>,|);serde_yamltolerated these, so configs that parsed before 2.4.0 — e.g.triggers: [:->,:>-]orword_separators: [:>-]— now fail with "did not find expected node content ... while parsing a flow node".Fix
New
parse_lenientparses strictly first; only on failure does it retry on a leniently re-quoted copy (lenient_flow_quote), which single-quotes bare flow-collection scalars that begin with:,>, or|. The retry-on-failure gate is the central safety property: every config that parses today is returned byte-for-byte untouched, and if the retry still fails the original error is returned — so genuinely malformed YAML fails exactly as before. Already-quoted scalars and#comments are skipped verbatim; feature/reserved indicators (*!&@%) are deliberately left strict (pre-2.4.0 did not accept them either).Wired into both YAML entry points:
config/parse/yaml.rsandmatches/group/loader/yaml/parse.rs.Test plan
cargo fmt --all -- --check— cleancargo clippy -p espanso-config --all-targets -- --deny warnings— cleancargo test -p espanso-config— 95 passed, 0 failed, including: the v2.4.0 doesn't parse unquoted values in- triggers:#2748 reproducer (:->,:>-,:-),:>hello), a zero-regression corpus of real espanso match/config shapes (proven value-identical strict vs lenient), and pathological-input robustness (unterminated quotes, NUL, 100k-deep nesting — all terminate).