w3c / qtspecs

XSLT and XQuery Specifications - the source used to build the specs, and the errata
Other
30 stars 27 forks source link

[fo31] deep-less-than algorithm used by fn:sort is flawed #19

Closed michaelhkay closed 2 years ago

michaelhkay commented 4 years ago

The deep-less-than($A, $B) algorithm used in the specification of fn:sort is incomplete. It does not properly handle the case where $B is empty and $A is not. In general it will return () in such cases, which could be interpreted as a false result, but in at least one case it returns true, specifically when comparing (NaN) to (). So deep-less-than(NaN, ()) and deep-less-than((), NaN) are both true, which makes the sort liable to non-termination.

michaelhkay commented 2 years ago

This has been fixed in the draft 4.0 specification.