@@ -6,8 +6,26 @@ use std::iter::repeat;
6
6
pub enum Error {
7
7
/// A syntax error.
8
8
Syntax ( String ) ,
9
- /// The compiled program exceeded the set size limit.
10
- /// The argument is the size limit imposed.
9
+ /// The compiled program exceeded the set size
10
+ /// limit. The argument is the size limit imposed by
11
+ /// [`RegexBuilder::size_limit`](crate::RegexBuilder::size_limit). Even
12
+ /// when not configured explicitly, it defaults to a reasonable limit.
13
+ ///
14
+ /// If you're getting this error, it occurred because your regex has been
15
+ /// compiled to an intermediate state that is too big. It is important to
16
+ /// note that exceeding this limit does _not_ mean the regex is too big to
17
+ /// _work_, but rather, the regex is big enough that it may wind up being
18
+ /// surprisingly slow when used in a search. In other words, this error is
19
+ /// meant to be a practical heuristic for avoiding a performance footgun,
20
+ /// and especially so for the case where the regex pattern is coming from
21
+ /// an untrusted source.
22
+ ///
23
+ /// There are generally two ways to move forward if you hit this error.
24
+ /// The first is to find some way to use a smaller regex. The second is to
25
+ /// increase the size limit via `RegexBuilder::size_limit`. However, if
26
+ /// your regex pattern is not from a trusted source, then neither of these
27
+ /// approaches may be appropriate. Instead, you'll have to determine just
28
+ /// how big of a regex you want to allow.
11
29
CompiledTooBig ( usize ) ,
12
30
/// Hints that destructuring should not be exhaustive.
13
31
///
0 commit comments