Skip to content

Raise when an XPath function name is unknown - #389

Open
adityawrk wants to merge 2 commits into
ruby:masterfrom
adityawrk:fix/unknown-xpath-function
Open

adityawrk wants to merge 2 commits into
ruby:masterfrom
adityawrk:fix/unknown-xpath-function

Conversation

@adityawrk

Copy link
Copy Markdown

Fixes #351.

An unknown function name was evaluated as an empty node-set. //foo[positoin()=1] matched nothing, and //*[namae()="bar"] did not say that namae is not a function, even when the document has an element of that name. The parser passed fallback: [] into Functions#call, which only raises when no fallback is given. The code marked that as not the XPath behavior and left it to reconsider.

Functions#call is now called without a fallback, so the name raises ArgumentError: Unknown XPath function: positoin. A known name still works, including local_name() outside strict mode, where _ is still rewritten to -. In strict mode local_name() is not a library function and raises too. Functions.send still accepts an unknown name and returns the empty fallback, as it did before.

ruby test/run.rb: 863 tests, 2743 assertions.

positoin() and namae() were accepted and evaluated as an empty
node-set, so a predicate with a typo matched nothing and a name
that was also an element name did not say it was unknown.
Evaluation passed an empty node-set as the fallback for a name
that is not in the function library. A typo then looked like a
predicate that matched nothing. Unknown names now raise
ArgumentError, which Functions#call already did when no fallback
was given.

Fixes ruby#351

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 function name typo silently ignored

1 participant