From f5bb9ab57b9153775a9ffca7322173ec424d4669 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 21 Jun 2022 18:09:24 +0200 Subject: Add support for capping destination (raw) balance --- src/construct/partial_destination.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/construct/partial_destination.rs') diff --git a/src/construct/partial_destination.rs b/src/construct/partial_destination.rs index 823ce99..b2ceeb8 100644 --- a/src/construct/partial_destination.rs +++ b/src/construct/partial_destination.rs @@ -57,6 +57,8 @@ pub struct Options { pub raw: TokenType, /// Token for a the string. pub string: TokenType, + /// Maximum unbalanced parens. + pub limit: usize, } /// State needed to parse destination. @@ -176,12 +178,9 @@ fn enclosed_escape(tokenizer: &mut Tokenizer, code: Code, info: Info) -> StateFn /// a|b /// ``` fn raw(tokenizer: &mut Tokenizer, code: Code, mut info: Info) -> StateFnResult { - // To do: configurable. - let limit = usize::MAX; - match code { Code::Char('(') => { - if info.balance >= limit { + if info.balance >= info.options.limit { (State::Nok, None) } else { tokenizer.consume(code); -- cgit