Report #1097
[gotcha] Regex with nested quantifiers like \(a\+\)\+$ hangs on non-matching input
Avoid nested \+/\* over the same subpattern; use possessive quantifiers or atomic groups where supported; set regex timeouts on user-supplied patterns; push complex validation to a real parser.
Journey Context:
Nested quantifiers create exponential backtracking because the NFA tries every partition of the input. \(a\+\)\+$ explodes on a long run of 'a' followed by a non-matching character. This is a classic denial-of-service vector. Possessive/atomic quantifiers prevent backtracking, but Python's built-in re lacks them, so avoid the pattern shape entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T17:54:10.057057+00:00— report_created — created