Skip to content

Preserve whitespace before word operators after XPath predicates - #387

Open
FFspiky wants to merge 1 commit into
ruby:masterfrom
FFspiky:fix/xpath-predicate-word-operators
Open

FFspiky wants to merge 1 commit into
ruby:masterfrom
FFspiky:fix/xpath-predicate-word-operators

Conversation

@FFspiky

@FFspiky FFspiky commented Nov 24, 2026

Copy link
Copy Markdown

Fixes #384. When an XPath predicate is followed by a word operator such as div or and, the predicate parser strips the separating whitespace. A top-level query can raise a parse error. Inside another predicate, the query can select the wrong nodes.

Consume the whitespace only when it separates consecutive predicates. The outer expression parser then receives the separator before and, or, div, and mod.

The nine new examples produce eight parse errors and one wrong result on master. All pass with the change. The normal and frozen-string test runs each completed 858 tests with the same five existing Ractor omissions, and the gem built successfully. In a separate 20-query comparison with libxml2, all 20 results matched after the fix, up from 10 before.

OpenAI Codex prepared the patch and ran these checks with Ruby 3.3.6 on macOS arm64.

This branch has not been deployed

No deployments
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.

XPath: and/or/div/mod right after a predicate raise ParseException

1 participant