DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
regex.cpp File Reference

Bounded regex route matcher for DetWebServer (used by on_regex() routes). More...

#include "dwserver.h"
#include "server/dwserver_internal.h"
#include <string.h>

Go to the source code of this file.

Classes

struct  ReCtx
 

Functions

bool regex_match (const char *pattern, const char *path)
 Whole-path regex match (anchored both ends; bounded by RE_MAX_STEPS, fails closed). Defined in server/regex.cpp, called by the route dispatcher for on_regex() routes.
 

Detailed Description

Bounded regex route matcher for DetWebServer (used by on_regex() routes).

Split out of dwserver.cpp (single-purpose server files). A small recursive backtracker over one pattern - literals, '.', quantifiers, character classes, and escapes - with a step budget (RE_MAX_STEPS) so a pathological pattern fails closed instead of backtracking unboundedly, preserving determinism. No heap, no groups, no alternation. The route dispatcher calls regex_match() (declared in server/dwserver_internal.h). Behaviour is identical to the pre-split code.

Definition in file regex.cpp.

Function Documentation

◆ regex_match()

bool regex_match ( const char *  pattern,
const char *  path 
)

Whole-path regex match (anchored both ends; bounded by RE_MAX_STEPS, fails closed). Defined in server/regex.cpp, called by the route dispatcher for on_regex() routes.

Definition at line 188 of file regex.cpp.

References ReCtx::max_steps, RE_MAX_STEPS, and ReCtx::steps.