|
lintel 0.2.0
|
#include <RegexUtils.h>
Static Public Member Functions | |
| static bool | validatePattern (const std::string &pattern, std::string &errorMessage) |
| static bool | matches (const std::string &pattern, const std::string &text) |
Static Public Attributes | |
| static constexpr std::size_t | kMaxPatternLength = 128 |
Hardening helpers for user-supplied regular expressions.
std::regex is vulnerable to catastrophic backtracking ("ReDoS"). These helpers apply a pragmatic heuristic layer before compiling a pattern: length limit, rejection of clearly pathological constructs, and a compilation check. They never throw on invalid input.
|
static |
Match text against a user-supplied pattern using the hardened checks. Never throws; returns false for invalid/unsafe patterns.
| pattern | the pattern to match |
| text | the text to match against |
|
static |
Validate a user-supplied pattern against basic ReDoS heuristics.
| pattern | the pattern to check |
| errorMessage | receives a human-readable reason on failure |
|
staticconstexpr |
Maximum allowed length of a user-supplied pattern.