From 17d8e76e0568eab500d4499067f6691ca17f2349 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Wed, 18 Oct 2023 08:52:18 -0400 Subject: [PATCH] Do not match POST for entities that end with a space. This is a special case for en-spaces. --- src/parser/entity.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/parser/entity.rs b/src/parser/entity.rs index aba5fd2c..84c271bb 100644 --- a/src/parser/entity.rs +++ b/src/parser/entity.rs @@ -1,11 +1,11 @@ use nom::branch::alt; use nom::bytes::complete::tag; use nom::character::complete::satisfy; +use nom::combinator::cond; use nom::combinator::eof; use nom::combinator::map; use nom::combinator::peek; use nom::combinator::recognize; -use nom::combinator::verify; use nom::sequence::tuple; use super::org_source::OrgSource; @@ -58,13 +58,16 @@ fn name<'b, 'g, 'r, 's>( for entity in context.get_global_settings().entities { let result = tuple(( tag::<_, _, CustomError>(entity.name), - alt(( - verify(map(tag("{}"), |_| true), |_| !entity.name.ends_with(' ')), - map(peek(recognize(entity_end)), |_| false), - )), + cond( + !entity.name.ends_with(' '), + alt(( + map(tag("{}"), |_| true), + map(peek(recognize(entity_end)), |_| false), + )), + ), ))(input); if let Ok((remaining, (ent, use_brackets))) = result { - return Ok((remaining, (entity, ent, use_brackets))); + return Ok((remaining, (entity, ent, use_brackets.unwrap_or(false)))); } }