mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 17:28:29 +00:00
Fix exception that occurs with libc++ regex engine (#368)
The regex that parses header lines potentially causes an unlimited amount of backtracking, which can cause an exception in the libc++ regex engine. The exception that occurs looks like this and is identical to the message of the exception fixed in https://github.com/yhirose/cpp-httplib/pull/280: libc++abi.dylib: terminating with uncaught exception of type std::__1::regex_error: The complexity of an attempted match against a regular expression exceeded a pre-set level. This commit eliminates the problematic backtracking.
This commit is contained in:
parent
3da925d6fe
commit
bf7700d192
2 changed files with 51 additions and 9 deletions
|
@ -1764,7 +1764,7 @@ inline bool read_headers(Stream &strm, Headers &headers) {
|
|||
// the left or right side of the header value:
|
||||
// - https://stackoverflow.com/questions/50179659/
|
||||
// - https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html
|
||||
static const std::regex re(R"((.+?):[\t ]*(.+))");
|
||||
static const std::regex re(R"(([^:]+):[\t ]*(.+))");
|
||||
|
||||
std::cmatch m;
|
||||
if (std::regex_match(line_reader.ptr(), end, m, re)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue