Skip to content

Commit 233e9a2

Browse files
committed
remove depth handling in parse_unary
1 parent 3d2aaa5 commit 233e9a2

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

src/parser.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,6 @@ impl<'toks, 'input> JSON5Parser<'toks, 'input> {
494494
match self.check_and_consume(vec![TokType::Plus, TokType::Minus]) {
495495
None => self.parse_primary(),
496496
Some(span) => {
497-
self.current_depth = self.current_depth + 1;
498-
if self.current_depth > self.max_depth {
499-
let idx = self.position();
500-
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))
501-
}
502497
match span.1 {
503498
TokType::Plus => {
504499
let value = self.parse_unary()?;
@@ -508,7 +503,6 @@ impl<'toks, 'input> JSON5Parser<'toks, 'input> {
508503
return Err(self.make_error(format!("Unary operations not allowed for value {:?}", val), span.2))
509504
}
510505
}
511-
self.current_depth = self.current_depth - 1;
512506
Ok(JSONValue::Unary {operator: UnaryOperator::Plus, value: Box::new(value)})
513507
}
514508
TokType::Minus => {
@@ -519,7 +513,6 @@ impl<'toks, 'input> JSON5Parser<'toks, 'input> {
519513
return Err(self.make_error(format!("Unary operations not allowed for value {:?}", val), span.2))
520514
}
521515
}
522-
self.current_depth = self.current_depth - 1;
523516
Ok(JSONValue::Unary {operator: UnaryOperator::Minus, value: Box::new(value)})
524517
}
525518
_ => unreachable!("no")

0 commit comments

Comments
 (0)