--- /dev/null
+pkg regexp/syntax, const ErrLarge = "expression too large" #56041
+pkg regexp/syntax, const ErrLarge ErrorCode #56041
{`a**`, "invalid nested repetition operator: `**`"},
{`a*+`, "invalid nested repetition operator: `*+`"},
{`\x`, "invalid escape sequence: `\\x`"},
+ {strings.Repeat(`\pL`, 27000), "expression too large"},
}
func compileTest(t *testing.T, expr string, error string) *Regexp {
ErrTrailingBackslash ErrorCode = "trailing backslash at end of expression"
ErrUnexpectedParen ErrorCode = "unexpected )"
ErrNestingDepth ErrorCode = "expression nests too deeply"
+ ErrLarge ErrorCode = "expression too large"
)
func (e ErrorCode) String() string {
func (p *parser) checkLimits(re *Regexp) {
if p.numRunes > maxRunes {
- panic(ErrInternalError)
+ panic(ErrLarge)
}
p.checkSize(re)
p.checkHeight(re)
}
if p.calcSize(re, true) > maxSize {
- panic(ErrInternalError)
+ panic(ErrLarge)
}
}
panic(r)
case nil:
// ok
- case ErrInternalError: // too big
- err = &Error{Code: ErrInternalError, Expr: s}
+ case ErrLarge: // too big
+ err = &Error{Code: ErrLarge, Expr: s}
case ErrNestingDepth:
err = &Error{Code: ErrNestingDepth, Expr: s}
}