Skip to content

🐛 fix(xsd): read length and digit facet limits exactly - #2247

Merged
gaborbernat merged 2 commits into
tox-dev:mainfrom
gaborbernat:fix/xsd-facet-limits-2232
Nov 16, 2026
Merged

gaborbernat merged 2 commits into
tox-dev:mainfrom
gaborbernat:fix/xsd-facet-limits-2232

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

The length and digit facets of an XSD simple type read their limit through a double and then stored it in an int. A maxLength or totalDigits above 2^53 therefore compared against a rounded limit, and a limit beyond the int range wrapped to a different number. Once this merges, minLength, maxLength, length, totalDigits and fractionDigits apply the limit the schema states, which XML Schema Part 2 requires to be a nonNegativeInteger. Fixes #2232.

Each limit is now read as an exact integer when the schema compiles, and the length and digit counts of a value are compared as the same integer type. A limit larger than the largest value a count can take is capped at that value, so it still accepts every value it accepted before.

Behavior changes

  • A limit beyond 2^31 or 2^53 is applied as written. A short value that was rejected by a maxLength above 2^53 is now accepted, and a short value that passed a minLength above 2^53 is now rejected.
  • A facet value that is not a plain integer keeps the integer it starts with, as before for a decimal such as 3.7. The exponent form 1e3 now reads as 1, where it read as 1000 before.

Length, minLength, maxLength, totalDigits and fractionDigits read their
limit through a double and stored it in an int. A limit above 2^53 was
rounded, and one beyond the int range wrapped to another number, so a
short value could be rejected by a large maxLength or accepted by a large
minLength. Each limit is now read as an exact integer when the schema
compiles, and a limit past the largest count saturates there.

Refs tox-dev#2232.
@gaborbernat gaborbernat added the bug Something isn't working label Nov 16, 2026
@gaborbernat
gaborbernat merged commit 2098f2c into tox-dev:main Nov 16, 2026
45 checks passed
@codspeed

codspeed Bot commented Nov 16, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 582 untouched benchmarks
⏩ 89 skipped benchmarks1


Comparing gaborbernat:fix/xsd-facet-limits-2232 (965e1ff) with main (7e6d0f9)

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. ↩

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 numeric facet bounds and limits are still read as doubles

1 participant