# HG changeset patch # User Olaf Wintermann # Date 1764096298 -3600 # Node ID 7b71e2973acc459418f5adac0cf239357ccd40fa # Parent 159172937c86907fd57168b56a302c5aa83d20eb save location match results diff -r 159172937c86 -r 7b71e2973acc src/server/daemon/location.c --- a/src/server/daemon/location.c Sun Nov 23 15:05:37 2025 +0100 +++ b/src/server/daemon/location.c Tue Nov 25 19:44:58 2025 +0100 @@ -96,7 +96,7 @@ WSLocationMatch match = WS_LOCATION_MATCH_EXACT; cxmutstr match_str; - int regex_flags = REG_EXTENDED | REG_NOSUB; + int regex_flags = REG_EXTENDED; int argc = serverconfig_directive_count_args(obj); if(argc == 2) { // arg0: match type @@ -176,13 +176,13 @@ return 0; } -int location_match(WSLocation *loc, cxstring uri) { +int location_match(WSLocation *loc, cxstring uri, regmatch_t *match) { if(loc->match == WS_LOCATION_MATCH_EXACT) { return !cx_strcmp(loc->match_string, uri); } else if(loc->match == WS_LOCATION_MATCH_PREFIX) { return cx_strprefix(uri, loc->match_string); } else { - return regexec(&loc->regex, uri.ptr, 0, NULL, 0) == 0; + return regexec(&loc->regex, uri.ptr, 0, match, WS_LOCATION_NMATCH) == 0; } return 0; } @@ -195,7 +195,7 @@ ZERO(config, sizeof(WSLocationConfig)); while(loc) { - if(location_match(loc, uri)) { + if(location_match(loc, uri, config->match)) { if(location_apply_config(config, loc)) { return NULL; } diff -r 159172937c86 -r 7b71e2973acc src/server/daemon/location.h --- a/src/server/daemon/location.h Sun Nov 23 15:05:37 2025 +0100 +++ b/src/server/daemon/location.h Tue Nov 25 19:44:58 2025 +0100 @@ -43,6 +43,8 @@ extern "C" { #endif +#define WS_LOCATION_NMATCH 16 + typedef struct WSLocation WSLocation; typedef struct WSLocationConfig WSLocationConfig; @@ -55,6 +57,11 @@ struct WSLocationConfig { /* + * location regex match results + */ + regmatch_t match[WS_LOCATION_NMATCH]; + + /* * Activate dirindex setting */ WSBool set_dirindex; @@ -146,7 +153,7 @@ WSLocation* cfg_location_get(ServerConfiguration *cfg, ConfigNode *obj); int location_apply_config(WSLocationConfig *target, WSLocation *loc); -int location_match(WSLocation *loc, cxstring uri); +int location_match(WSLocation *loc, cxstring uri, regmatch_t *match); WSLocationConfig* location_match_and_get_config(pool_handle_t *pool, cxstring uri, WSLocation *loc); WSLocationConfig* cfg_location_match(Session *sn, Request *rq);