Skip to content

🐛 fix(xsd): reject NaN under bounded float facets - #1968

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

gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:sec-fix/ig6qc0l0

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

XMLSchema accepted a NaN element or attribute value of a bounded xs:double or xs:float as valid. The range checks rejected a value only when a comparison was true, and every comparison with NaN is false, so NaN passed every bound. ⚡ Once this merges, NaN fails the bounds and is reported with the existing below or above message, as RELAX NG validation already does. Fixes #1736

XML Schema excludes NaN from a bounded float or double (XML Schema Part 2). 🧭 Each range check now rejects a value that does not meet its facet, instead of one that breaks it. For two ordered numbers the two forms agree, so finite values and infinities keep their verdicts.

  • A NaN value of a bounded xs:double or xs:float is now invalid.
  • A bound that is itself NaN now rejects every value. Before, it accepted every value.

The four range checks in facet_check() tested for the violation, such as
number < minInclusive. An ordered comparison with NaN is false, so NaN
passed every bound and XMLSchema reported a NaN value of a bounded
xs:double or xs:float as valid. XML Schema Part 2 excludes NaN from such a
type, and the RELAX NG validator already rejects it.

The checks now negate what each facet requires, so an unordered NaN fails
every bound. Finite values and infinities get the same verdicts as before,
and an unbounded NaN stays valid.
@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 improve performance by 7.1%

2 warnings

⚠️ 2 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 2 benchmarks with a significant change ran in a different software environment

Their base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the changes might come from this difference rather than from the code. Open an affected benchmark to see what changed.

See affected benchmarks

⚡ 2 improved benchmarks
✅ 580 untouched benchmarks
⏩ 89 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_feature[form-data-fieldsets-enabled] 1.4 ms 1.3 ms +9.07%
⚡ test_feature[form-data-fieldsets] 32.7 µs 31 µs +5.18%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing gaborbernat:sec-fix/ig6qc0l0 (7113e5f) with main (e5d5084)2

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

  2. No successful run was found on main (785ecb6) during the generation of this report, so e5d5084 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@gaborbernat
gaborbernat merged commit 3b461b7 into tox-dev:main Nov 15, 2026
31 checks passed
gaborbernat added a commit to gaborbernat/turbohtml that referenced this pull request Nov 16, 2026
XML Schema makes NaN equal to itself and unordered with every other
float or double. An inclusive NaN bound therefore admits only NaN, and
an exclusive NaN bound admits no value. Both validators rejected every
value instead, NaN included.

Decimal and integer bounds were compared as doubles, which rounds long
literals: a negative value too small for a double read as zero and
passed minInclusive 0, and integers past 2^53 compared equal to their
neighbors. Range facets on decimal and integer types now compare the
digits as written. List items and RELAX NG datatypes follow the same
rules.

Refs tox-dev#1736, follows tox-dev#1968.
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.

XMLSchema accepts NaN for bounded xs:double and xs:float

1 participant