Do not match POST for entities that end with a space.

This is a special case for en-spaces.
This commit is contained in:
Tom Alexander 2023-10-18 08:52:18 -04:00
parent 8db9038c53
commit 17d8e76e05
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 9 additions and 6 deletions

View File

@ -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))));
}
}