From 1db8f4aa135d45995d2d19a0cf8b08044b5e0478 Mon Sep 17 00:00:00 2001 From: Wilson Lin Date: Sat, 28 Dec 2019 11:21:44 +1100 Subject: [PATCH] Enforce no whitespace between attribute name and value --- src/unit/attr/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/unit/attr/mod.rs b/src/unit/attr/mod.rs index c6458fd..d84e66f 100644 --- a/src/unit/attr/mod.rs +++ b/src/unit/attr/mod.rs @@ -35,8 +35,9 @@ fn is_name_char(c: u8) -> bool { } pub fn process_attr(proc: &mut Processor) -> ProcessingResult { - // Expect `process_attr` to be called at an attribute. - let name = chain!(proc.match_while_pred(is_name_char).expect().keep().range()); + // It's possible to expect attribute name but not be called at an attribute, e.g. due to whitespace between name and + // value, which causes name to be considered boolean attribute and `=` to be start of new (invalid) attribute name. + let name = chain!(proc.match_while_pred(is_name_char).require_with_reason("attribute name")?.keep().range()); let after_name = proc.checkpoint(); // TODO DOC Attr must be case sensitive