In traditional mode ($wgExperimentalHtmlIds = false) Sanitizer::escapeId generates ambiguous values:
Sanitizer::escapeId( '!', [ 'noninitial' ] ) and Sanitizer::escapeId( '.21', [ 'noninitial' ] ) evaluates to .21.
A heuristic decoding would generate relevant errors. For example the heading
172.31.255.255
gets encoded to id="172.31.255.255" and a heuristic decoder would generate 1721%5%5.
It would be possible to generate nonambiguous values by encoding . with .2E. Sanitizer::escapeId( '.21', [ 'noninitial' ] ) would evaluate to .2E21.
Such a change would be easy to implement by adding
'.' => '%2E',
But such a change is not backward compatible. Existing anchor links to headings can break.