Repository navigation
Commit 5de4b19
committed
Fix panic in BoundedBacktracker when haystack length exceeds capacity
Issue #1344: When a regex like /^.{0,404600}$/ causes the bounded
backtracker's max_haystack_len() to return 0, the meta layer's guard
in wrappers.rs used '>' instead of '>=', allowing the engine to be
selected for an empty string (length 0). The engine then panicked with
MatchError(HaystackTooLong { len: 0 }) from an unwrap().
The fix changes the guard from '>' to '>=' so that when
max_haystack_len() is 0, no haystack (including the empty string)
is excluded from the backtracker engine.
Added regression test max_haystack_len_zero_excludes_engine.1 parent 72d650c commit 5de4b19
2 files changed
Lines changed: 31 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
180 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
181 | 184 | | |
182 | 185 | | |
183 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1905 | 1905 | | |
1906 | 1906 | | |
1907 | 1907 | | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
1908 | 1934 | | |
0 commit comments