aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/construct/character_reference.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/construct/character_reference.rs b/src/construct/character_reference.rs
index 04e89d2..4f2505d 100644
--- a/src/construct/character_reference.rs
+++ b/src/construct/character_reference.rs
@@ -62,8 +62,8 @@
//! [html]: https://html.spec.whatwg.org/multipage/parsing.html#character-reference-state
use crate::constant::{
- CHARACTER_REFERENCE_DECIMAL_SIZE_MAX, CHARACTER_REFERENCE_HEXADECIMAL_SIZE_MAX,
- CHARACTER_REFERENCE_NAMED_SIZE_MAX, CHARACTER_REFERENCE_NAMES,
+ CHARACTER_REFERENCES, CHARACTER_REFERENCE_DECIMAL_SIZE_MAX,
+ CHARACTER_REFERENCE_HEXADECIMAL_SIZE_MAX, CHARACTER_REFERENCE_NAMED_SIZE_MAX,
};
use crate::token::Token;
use crate::tokenizer::{Code, State, StateFnResult, Tokenizer};
@@ -189,10 +189,12 @@ fn numeric(tokenizer: &mut Tokenizer, code: Code, mut info: Info) -> StateFnResu
fn value(tokenizer: &mut Tokenizer, code: Code, mut info: Info) -> StateFnResult {
match code {
Code::Char(';') if !info.buffer.is_empty() => {
- if Kind::Named == info.kind
- && !CHARACTER_REFERENCE_NAMES
- .contains(&info.buffer.iter().collect::<String>().as_str())
- {
+ let unknown_named = Kind::Named == info.kind && {
+ let value = info.buffer.iter().collect::<String>();
+ !CHARACTER_REFERENCES.iter().any(|d| d.0 == value)
+ };
+
+ if unknown_named {
(State::Nok, None)
} else {
tokenizer.exit(Token::CharacterReferenceValue);