From afb44f01576d5a1cae7fbbed145f5af6f176536b Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 22 Jun 2018 20:23:38 +0200 Subject: Disallow user-defined macros named 'super' --- askama_derive/src/parser.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'askama_derive') diff --git a/askama_derive/src/parser.rs b/askama_derive/src/parser.rs index fb591d4..96e0f09 100644 --- a/askama_derive/src/parser.rs +++ b/askama_derive/src/parser.rs @@ -623,15 +623,20 @@ named!(block_macro, do_parse!( pws2: opt!(tag_s!("-")) >> ws!(tag_s!("endmacro")) >> nws2: opt!(tag_s!("-")) >> - (Node::Macro( - name, - Macro { - ws1: WS(pws1.is_some(), nws1.is_some()), - args: params, - nodes: contents, - ws2: WS(pws2.is_some(), nws2.is_some()) - } - )) + ({ + if name == "super" { + panic!("invalid macro name 'super'"); + } + Node::Macro( + name, + Macro { + ws1: WS(pws1.is_some(), nws1.is_some()), + args: params, + nodes: contents, + ws2: WS(pws2.is_some(), nws2.is_some()) + } + ) + }) )); named!(block_node, do_parse!( -- cgit