From a90b065f46e209f4adb94139c948c8a1bdfaffdf Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 4 Aug 2017 15:57:49 +0200 Subject: Let parse() panic if template is not parsed completely (fixes #27) --- askama_derive/src/parser.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/askama_derive/src/parser.rs b/askama_derive/src/parser.rs index d5cea5b..8b5ec4e 100644 --- a/askama_derive/src/parser.rs +++ b/askama_derive/src/parser.rs @@ -364,7 +364,14 @@ named!(parse_template>>, many0!(alt!( pub fn parse(src: &str) -> Vec { match parse_template(src.as_bytes()) { - IResult::Done(_, res) => res, + IResult::Done(left, res) => { + if left.len() > 0 { + let s = str::from_utf8(left).unwrap(); + panic!("unable to parse template:\n\n{:?}", s); + } else { + res + } + }, IResult::Error(err) => panic!("problems parsing template source: {}", err), IResult::Incomplete(_) => panic!("parsing incomplete"), } -- cgit