Skip to content

🐛 fix(xsd): check ID and g* lexical forms - #2185

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:sec-fix/n50-xsd-builtins
Nov 15, 2026
Merged

gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:sec-fix/n50-xsd-builtins

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Schemas that name ID, IDREF, ENTITY, NOTATION or one of the g* date types accepted any text for those values, because the engine had no lexical check for them. 🧾 Once this merges, a value outside the XSD 1.0 form fails with a datatype error, in both XML Schema and RELAX NG validation. Fixes #2159.

The built-in datatype table had no entry for these nine names, so each one fell back to xs:string. The table now has an entry for each, and each entry routes to its lexical check: an NCName check for ID, IDREF and ENTITY, a QName check for NOTATION, and a check of the reduced date form for each g* type (XSD 1.0 Part 2, gYear). The RELAX NG <data> element that uses the XSD datatype library reads the same table, so both validators share one rule set.

Behavior changes

  • A value outside the lexical form of one of these types fails with a datatype error, for XML Schema element and attribute types, types derived from them, and RELAX NG <data> with the XSD datatype library.
  • These types collapse whitespace, as XSD gives them, instead of preserving it. A pattern or enumeration facet on one of them sees the collapsed value.
  • Length facets and enumerations still compare the string form. Range facets on the g* types stay unchecked, because the engine has no ordering for those types.

The built-in datatype table had no entries for ID, IDREF, ENTITY,
NOTATION, gYear, gYearMonth, gMonth, gMonthDay and gDay. A schema that
named one of them fell back to xs:string, so XMLSchema and RelaxNG
accepted any text for it. Both engines resolve built-in names through
that table, so the nine types now get their XSD 1.0 lexical checks
there: NCName for ID, IDREF and ENTITY, QName for NOTATION, and the
Part 2 forms for the g* date types. The name list that kept these types
as string fallbacks drops them.
@gaborbernat gaborbernat added the bug Something isn't working label Nov 15, 2026
@codspeed

codspeed Bot commented Nov 15, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 582 untouched benchmarks
⏩ 89 skipped benchmarks1


Comparing gaborbernat:sec-fix/n50-xsd-builtins (cf90a0c) with main (9fdbc4e)

Open in CodSpeed

Footnotes

  1. 89 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@gaborbernat
gaborbernat merged commit 612eda8 into tox-dev:main Nov 15, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XSD ID, IDREF, ENTITY, NOTATION and g* types accept any string

1 participant