From b0a2ce50ecb1a1531b2f7dc4591c9809bb23ed55 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 15 Jul 2022 18:22:57 +0200 Subject: Fix to use single array for character references --- src/construct/character_reference.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/construct/character_reference.rs') 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::().as_str()) - { + let unknown_named = Kind::Named == info.kind && { + let value = info.buffer.iter().collect::(); + !CHARACTER_REFERENCES.iter().any(|d| d.0 == value) + }; + + if unknown_named { (State::Nok, None) } else { tokenizer.exit(Token::CharacterReferenceValue); -- cgit