The fix for #51112 introduced a depth check but used
ErrInternalError to avoid introduce new API in a CL that
would be backported to earlier releases.
New API accepted in proposal #51684.
This CL adds a distinct error for this case.
For #51112.
Fixes #51684.
Change-Id: I068fc70aafe4218386a06103d9b7c847fb7ffa65
Reviewed-on: https://go-review.googlesource.com/c/go/+/384617
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
--- /dev/null
+pkg regexp/syntax, const ErrInvalidDepth = "invalid nesting depth" #0
+pkg regexp/syntax, const ErrInvalidDepth ErrorCode #0
+
ErrMissingRepeatArgument ErrorCode = "missing argument to repetition operator"
ErrTrailingBackslash ErrorCode = "trailing backslash at end of expression"
ErrUnexpectedParen ErrorCode = "unexpected )"
+ ErrInvalidDepth ErrorCode = "invalid nesting depth"
)
func (e ErrorCode) String() string {
}
}
if p.calcHeight(re, true) > maxHeight {
- panic(ErrInternalError)
+ panic(ErrInvalidDepth)
}
}
panic(r)
case nil:
// ok
- case ErrInternalError:
- err = &Error{Code: ErrInternalError, Expr: s}
+ case ErrInvalidDepth:
+ err = &Error{Code: ErrInvalidDepth, Expr: s}
}
}()