* Normalizes attribute value per XML 1.0 §3.3.3. * * Only predefined entities are expanded (lt, gt, amp, apos, quot). * Custom entities from DTD are NOT expanded. * * @see https://www.w3.org/TR/xml/#AVNormalize
(raw: string, xml11: boolean)
| 36 | * @see {@link https://www.w3.org/TR/xml/#AVNormalize} |
| 37 | */ |
| 38 | function normalizeAttributeValue(raw: string, xml11: boolean): string { |
| 39 | // Replace literal \t and \n with space BEFORE entity decoding (preserves ) |
| 40 | const normalized = raw.includes("\t") || raw.includes("\n") |
| 41 | ? raw.replace(/[\t\n]/g, " ") |
| 42 | : raw; |
| 43 | return decodeEntities(normalized, xml11); |
| 44 | } |
| 45 | |
| 46 | /** Threshold above which duplicate detection switches from linear scan to Set. */ |
| 47 | const ATTR_SET_THRESHOLD = 32; |
no test coverage detected