Skip to content

fix(posture): avoid panic when unquoting a lone quote character - #45

Merged
orielhaim merged 1 commit into
tunnetio:mainfrom
Jacob-9909:fix/posture-unquote-lone-quote
Oct 15, 2026
Merged

orielhaim merged 1 commit into
tunnetio:mainfrom
Jacob-9909:fix/posture-unquote-lone-quote

Conversation

@Jacob-9909

Copy link
Copy Markdown
Contributor

Summary

unquote in tunnet-posture panicked on a value consisting of a single ' or " (e.g. device:x == '), because it sliced s[1..len-1] once the value started and ended with the same quote. Malformed assertions from posture definitions now parse as a literal instead of panicking.

Changes

  • Replaced the index slicing in unquote (crates/tunnet-posture/src/evaluate.rs) with strip_prefix/strip_suffix
  • Added parses_unbalanced_quotes_verbatim rstest cases covering value, list item and function-argument positions

Testing

  • Ran local test suite (cargo test -p tunnet-posture --lib, Rust 1.98.1 on Linux): all 23 tests passed. The new cases panic at evaluate.rs:109 without the fix.
  • cargo fmt --all -- --check and cargo clippy -p tunnet-posture --all-targets: clean.

unquote sliced s[1..len-1] whenever the trimmed value started and ended
with the same quote, so a single ' or " (e.g. `device:x == '`) panicked
instead of being kept as a literal. Use strip_prefix/strip_suffix.
@CLAassistant

CLAassistant commented Oct 15, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@orielhaim
orielhaim merged commit 75b317b into tunnetio:main Oct 15, 2026
13 checks passed
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.

3 participants