Skip to content

Commit 9325c3e

Browse files
committed
remove depth handling in parse_unary (rt)
1 parent 233e9a2 commit 9325c3e

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

src/rt/parser.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -609,11 +609,6 @@ impl<'toks, 'input> JSON5Parser<'toks, 'input> {
609609
match self.check_and_consume(vec![TokType::Plus, TokType::Minus]) {
610610
None => self.parse_primary(),
611611
Some(span) => {
612-
self.current_depth = self.current_depth + 1;
613-
if self.current_depth > self.max_depth {
614-
let idx = self.position();
615-
return Err(self.make_error(format!("max depth ({}) exceeded while parsing unary. To expand the depth, use the ``with_max_depth`` constructor or enable the `unlimited_depth` feature", self.max_depth), idx))
616-
}
617612
match span.1 {
618613
TokType::Plus => {
619614
let value = self.parse_unary()?;
@@ -623,7 +618,6 @@ impl<'toks, 'input> JSON5Parser<'toks, 'input> {
623618
return Err(self.make_error(format!("Unary operations not allowed for value {:?}", val), span.2))
624619
}
625620
}
626-
self.current_depth = self.current_depth - 1;
627621
Ok(JSONValue::Unary {operator: UnaryOperator::Plus, value: Box::new(value)})
628622
}
629623
TokType::Minus => {
@@ -634,7 +628,6 @@ impl<'toks, 'input> JSON5Parser<'toks, 'input> {
634628
return Err(self.make_error(format!("Unary operations not allowed for value {:?}", val), span.2))
635629
}
636630
}
637-
self.current_depth = self.current_depth - 1;
638631
Ok(JSONValue::Unary {operator: UnaryOperator::Minus, value: Box::new(value)})
639632
}
640633
_ => unreachable!("no")

0 commit comments

Comments
 (0)