Documentation
¶
Overview ¶
Package xmlchar holds the character-level rules of XML 1.0 that every byte-level scanner in this framework needs.
It exists because the rules were copied instead of shared, and the copy went wrong. pkg/core/packet/parser_fast.go had a character-reference decoder that accepted `�`, control characters, surrogates and FFFE/FFFF — values XML has no way to represent — while encoding/xml rejects a document containing them. That was fixed in 1.19.2 by implementing the Char production from XML 1.0 §2.2. When pkg/xlsx grew its own scanner it grew its own decoder alongside, without that check, and the same bug came back: the fast path accepted `` and `` where the reference decoder errored.
A fast path that is more permissive than the parser it falls back to is worse than no fast path, because the result then depends on which one ran. One implementation, one set of tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeRef ¶
DecodeRef parses the body of a numeric character reference — the part between "&#" and ";", so "60" or "x3C" — and returns the rune it denotes.
ok=false covers every reason the reference is unusable: empty, a digit the base does not allow, a value past the Unicode maximum, or a code point the Char production forbids. The caller is expected to treat that as "this document is not something I can parse", not as a value to substitute.
func IsChar ¶
IsChar reports whether r is allowed as a character in an XML 1.0 document — the Char production of §2.2:
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
Excluded, and each for its own reason: most C0 controls have no representation at all; the surrogate range D800–DFFF is only meaningful inside UTF-16 and is not a character; FFFE and FFFF are permanently unassigned byte-order-mark sentinels.
Types ¶
This section is empty.