From 9c5f0bba84e7eddbd219e63de3e7f380441dbdfd Mon Sep 17 00:00:00 2001 From: daku10 Date: Sun, 7 Jan 2024 01:00:43 +0900 Subject: [PATCH] improve validation using all_consuming in parser --- src/parser.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index e3b322c..22eb330 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -2,6 +2,7 @@ use crate::{canonicalization, hash, DKIMError}; use nom::bytes::complete::tag; use nom::bytes::complete::take_while1; use nom::character::complete::alpha1; +use nom::combinator::all_consuming; use nom::combinator::opt; use nom::multi::fold_many0; use nom::sequence::delimited; @@ -27,7 +28,7 @@ pub struct Tag { pub fn tag_list(input: &str) -> IResult<&str, Vec> { let (input, start) = tag_spec(input)?; - terminated( + all_consuming(terminated( fold_many0( preceded(tag(";"), tag_spec), move || vec![start.clone()], @@ -37,7 +38,7 @@ pub fn tag_list(input: &str) -> IResult<&str, Vec> { }, ), opt(tag(";")), - )(input) + ))(input) } /// tag-spec = [FWS] tag-name [FWS] "=" [FWS] tag-value [FWS]