From e86c87af3cb5cfd1efca2da215ad09a9ca694148 Mon Sep 17 00:00:00 2001 From: Mihaela Mihaljevic Date: Tue, 9 Jun 2026 05:11:18 +0200 Subject: [PATCH] feat(html): numeric-ref validation, NUL, RCDATA decoding, semicolon-less refs (#84) --- CHANGELOG.md | 1 + README.md | 2 +- Sources/HTML/HTMLEntities.swift | 107 ++++++++++++++++++++++++------- Sources/HTML/HTMLToken.swift | 5 ++ Sources/HTML/HTMLTokenizer.swift | 7 +- Tests/HTMLTokenizerTests.swift | 53 +++++++++++++++ 6 files changed, 150 insertions(+), 25 deletions(-) create mode 100644 Tests/HTMLTokenizerTests.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index f345098..8ccb748 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- HTML tokenizer correctness (#84, partial): numeric character references are now range/surrogate-validated (zero, surrogates, and values above U+10FFFF yield U+FFFD) with the Windows-1252 C1 fixup table (`€` -> euro, etc.); named references are decoded by longest match with or without a trailing semicolon; a literal NUL byte becomes U+FFFD; RCDATA elements (`title`, `textarea`) decode character references while raw-text elements (`script`, `style`) take their content verbatim; and a single leading newline after `") == "") + #expect(text("") == "a & b") + } + + @Test("A single leading newline after ") == "hello") + #expect(text("") == "\nhello") + } +}