Skip to content

Report invalid selectors without panicking - #87

Open
VrtxOmega wants to merge 1 commit into
mgdm:masterfrom
VrtxOmega:fix/65-selector-parse-error
Open

Report invalid selectors without panicking#87
VrtxOmega wants to merge 1 commit into
mgdm:masterfrom
VrtxOmega:fix/65-selector-parse-error

Conversation

@VrtxOmega

Copy link
Copy Markdown

Fixes #65.

Problem

Unsupported CSS selectors such as div:has(h1) make htmlq panic while parsing the selector. The CLI exits 101 and can emit a Rust backtrace instead of a user-facing error.

Change

Handle the selector parser error explicitly, print the exact invalid selector, and exit with status 2.

This does not add :has support or change successful selector behavior.

Verification

  • Reproduced the original exit 101 panic on current master
  • Added a regression test requiring exit 2 and no panic
  • cargo test --all-targets — 10 passed, 0 failed
  • Manual invalid-selector check — exit 2, exact diagnostic, no panic
  • Manual valid div selector check — output unchanged

Risk

Low. The change affects only selector-parse failures and adds no dependency.

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.

Panic with :has selector

1 participant