From af1f97dbf5a40740e26eb4f705a0bd744744807b Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 18 Mar 2024 10:31:00 -0500 Subject: [PATCH] refactor(parser): Pull recursion limit out to variable --- crates/toml_edit/src/parser/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/toml_edit/src/parser/mod.rs b/crates/toml_edit/src/parser/mod.rs index eda3bc54..70e372c8 100644 --- a/crates/toml_edit/src/parser/mod.rs +++ b/crates/toml_edit/src/parser/mod.rs @@ -98,10 +98,13 @@ pub(crate) mod prelude { current: usize, } + #[cfg(not(feature = "unbounded"))] + const LIMIT: usize = 128; + #[cfg(not(feature = "unbounded"))] impl RecursionCheck { pub(crate) fn check_depth(depth: usize) -> Result<(), super::error::CustomError> { - if depth < 128 { + if depth < LIMIT { Ok(()) } else { Err(super::error::CustomError::RecursionLimitExceeded) @@ -113,7 +116,7 @@ pub(crate) mod prelude { input: &mut Input<'_>, ) -> Result> { self.current += 1; - if self.current < 128 { + if self.current < LIMIT { Ok(self) } else { Err(winnow::error::ErrMode::from_external_error(