()
| 770 | } |
| 771 | |
| 772 | function readText(): string { |
| 773 | const start = pos; |
| 774 | const idx = input.indexOf("<", pos); |
| 775 | const end = idx === -1 ? len : idx; |
| 776 | |
| 777 | for (let i = start; i < end; i++) { |
| 778 | const code = input.charCodeAt(i); |
| 779 | if (isIllegalLiteralChar(code)) { |
| 780 | pos = i; |
| 781 | error( |
| 782 | `Illegal XML character U+${ |
| 783 | code.toString(16).toUpperCase().padStart(4, "0") |
| 784 | }`, |
| 785 | ); |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | pos = end; |
| 790 | |
| 791 | // Slice text once (reused for ]]> check and entity decoding) |
| 792 | const text = input.slice(start, end); |
| 793 | |
| 794 | // XML 1.0 §2.4: "]]>" is not allowed in text content |
| 795 | if (text.includes("]]>")) { |
| 796 | pos = start + text.indexOf("]]>"); |
| 797 | error("Cannot use ']]>' in text content (XML 1.0 §2.4)"); |
| 798 | } |
| 799 | |
| 800 | return decodeEntities(text, xml11); |
| 801 | } |
| 802 | |
| 803 | function addNode(node: XmlTextNode | XmlCDataNode | XmlCommentNode): void { |
| 804 | if (stack.length > 0) { |
no test coverage detected