Don't match a language prefix that is not a sublanguage in lang() - #373
Merged
Merged
Conversation
XPath 1.0 lang() is true when xml:lang equals the argument or is a
sublanguage of it, i.e. the argument followed by '-'. compare_language
only checked for a prefix, so lang('en') also matched xml:lang="eng".
Member
|
Good catch. I've added the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
XPath 1.0
lang()is true whenxml:langequals the argument or is a sublanguage of it (the argument followed by-), ignoring case.compare_languageonly checks for a prefix, solang('en')also matchesxml:lang="eng"://p[lang('en')]overen,eng,EN-us,een,eng,EN-usen,EN-usen,EN-us//p[lang('e')]ee//p[lang('en-US')]EN-usEN-usEN-ushttps://www.w3.org/TR/xpath-10/#function-lang
The new test sits next to
test_lang; it fails on master and passes here.ruby -Ilib test/run.rbpasses on Ruby 3.4 (also with--enable-frozen-string-literal), and the lang tests pass on 2.7.Written with AI assistance (Claude); I have reviewed the change.