On Fri, Apr 14, 2023 at 4:02 PM <minf...@apache.org> wrote: > > Author: minfrin > Date: Fri Apr 14 14:02:11 2023 > New Revision: 1909135 > > URL: http://svn.apache.org/viewvc?rev=1909135&view=rev > Log: > core: Be explicit if an enclosing directive contains a path or a > regex.
Currently all the tests (framework) are broken due to cmd->regex not being properly stacked/scoped. If cmd->regex is to be used to store the enclosing section's regex, it should be saved and restored by *all* the the sections (much like cmd->override is saved/restored using the old_overrides stack variable in most sections). It should also be set to NULL when parsing (sub-)sections with no possible regex, unless we want to inherit cmd->regex there. But for instance some like: <Location ...> <If ...> # use /fake from <Location> Alias /real </If> </Location> won't work for Alias because <If> overwrites cmd->path with "*If". Also, what about: <DirectoryMatch ...> <FilesMatch ...> # which regex here? </FilesMatch> </DirectoryMatch> Or: <DirectoryMatch ...> <Files ...> # <DirectoryMatch>'s regex usable here? </Files> </DirectoryMatch> ? Or third-party sections (unaware of cmd->regex) which contain directives that depend on cmd->regex? I'm not saying it's a bad idea but it needs more changes than this commit, changes that spread all over the code base it seems (modules can have their sections too), something like: $ grep -r 'AP_INIT\w\+("<' server/ modules/ 2>/dev/null server/core.c:AP_INIT_RAW_ARGS("<Directory", dirsection, NULL, RSRC_CONF, server/core.c:AP_INIT_RAW_ARGS("<Location", urlsection, NULL, RSRC_CONF, server/core.c:AP_INIT_RAW_ARGS("<VirtualHost", virtualhost_section, NULL, RSRC_CONF, server/core.c:AP_INIT_RAW_ARGS("<Files", filesection, NULL, OR_ALL, server/core.c:AP_INIT_RAW_ARGS("<Limit", ap_limit_section, NULL, OR_LIMIT | OR_AUTHCFG, server/core.c:AP_INIT_RAW_ARGS("<LimitExcept", ap_limit_section, (void*)1, server/core.c:AP_INIT_RAW_ARGS("<IfModule", start_cond_section, (void *)test_ifmod_section, server/core.c:AP_INIT_RAW_ARGS("<IfDefine", start_cond_section, (void *)test_ifdefine_section, server/core.c:AP_INIT_RAW_ARGS("<IfFile", start_cond_section, (void *)test_iffile_section, server/core.c:AP_INIT_RAW_ARGS("<IfDirective", start_cond_section, (void *)test_ifdirective_section, server/core.c:AP_INIT_RAW_ARGS("<IfSection", start_cond_section, (void *)test_ifsection_section, server/core.c:AP_INIT_RAW_ARGS("<DirectoryMatch", dirsection, (void*)1, RSRC_CONF, server/core.c:AP_INIT_RAW_ARGS("<LocationMatch", urlsection, (void*)1, RSRC_CONF, server/core.c:AP_INIT_RAW_ARGS("<FilesMatch", filesection, (void*)1, OR_ALL, server/core.c:AP_INIT_RAW_ARGS("<If", ifsection, COND_IF, OR_ALL, server/core.c:AP_INIT_RAW_ARGS("<ElseIf", ifsection, COND_ELSEIF, OR_ALL, server/core.c:AP_INIT_RAW_ARGS("<Else", ifsection, COND_ELSE, OR_ALL, modules/metadata/mod_version.c: AP_INIT_TAKE123("<IfVersion", start_ifversion, NULL, EXEC_ON_READ | OR_ALL, modules/aaa/mod_authn_core.c: AP_INIT_RAW_ARGS("<AuthnProviderAlias", authaliassection, NULL, RSRC_CONF, modules/aaa/mod_authz_core.c: AP_INIT_RAW_ARGS("<AuthzProviderAlias", authz_require_alias_section, modules/aaa/mod_authz_core.c: AP_INIT_RAW_ARGS("<RequireAll", add_authz_section, NULL, OR_AUTHCFG, modules/aaa/mod_authz_core.c: AP_INIT_RAW_ARGS("<RequireAny", add_authz_section, NULL, OR_AUTHCFG, modules/aaa/mod_authz_core.c: AP_INIT_RAW_ARGS("<RequireNotAll", add_authz_section, NULL, OR_AUTHCFG, modules/aaa/mod_authz_core.c: AP_INIT_RAW_ARGS("<RequireNone", add_authz_section, NULL, OR_AUTHCFG, modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookPreTranslateName", register_pre_trans_name_block, NULL, modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookTranslateName", register_translate_name_block, modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookFixups", register_fixups_block, NULL, modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookMapToStorage", register_map_to_storage_block, modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookCheckUserID", register_check_user_id_block, modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookTypeChecker", register_type_checker_block, NULL, modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookAccessChecker", register_access_checker_block, modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaHookAuthChecker", register_auth_checker_block, NULL, modules/lua/mod_lua.c: AP_INIT_RAW_ARGS("<LuaQuickHandler", register_quick_block, NULL, modules/proxy/mod_proxy.c: AP_INIT_RAW_ARGS("<Proxy", proxysection, NULL, RSRC_CONF, modules/proxy/mod_proxy.c: AP_INIT_RAW_ARGS("<ProxyMatch", proxysection, (void*)1, RSRC_CONF, (possibly not all of them need care though) Maybe we only want to check that the parent directive is a <Location> with Alias for now? Regards; Yann.