mirror of
https://github.com/apache/httpd.git
synced 2025-07-02 18:02:27 +03:00
Follow up to r1873941: define AP_REG_NO_DEFAULT for raw ap_regcomp() usage.
This avoids having to define AP_REG_NO_* for each APR_REG_* specific option, thus replacing AP_REG_NO_DOTALL introduced lately. For ap_rxplus_compile() and mod_substitute where default AP_REG_DOTALL is not suitable, let's use: AP_REG_NO_DEFAULT | ap_regcomp_get_default_cflags() & AP_REG_DOLLAR_ENDONLY to keep the default AP_REG_DOLLAR_ENDONLY unless RegexDefaultOptions unsets it. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1874090 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@ -620,7 +620,7 @@
|
|||||||
* 20190312.6 (2.5.1-dev) Add proxy check_trans hook
|
* 20190312.6 (2.5.1-dev) Add proxy check_trans hook
|
||||||
* 20190312.7 (2.5.1-dev) AP_REG_DEFAULT macro in ap_regex.h
|
* 20190312.7 (2.5.1-dev) AP_REG_DEFAULT macro in ap_regex.h
|
||||||
* 20190312.8 (2.5.1-dev) ap_is_chunked() in httpd.h
|
* 20190312.8 (2.5.1-dev) ap_is_chunked() in httpd.h
|
||||||
* 20190312.9 (2.5.1-dev) AP_REG_NO_DOTALL macro in ap_regex.h
|
* 20190312.9 (2.5.1-dev) AP_REG_NO_DEFAULT macro in ap_regex.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
|
#define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
|
||||||
|
@ -87,7 +87,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define AP_REG_DOLLAR_ENDONLY 0x200 /**< '$' matches at end of subject string only */
|
#define AP_REG_DOLLAR_ENDONLY 0x200 /**< '$' matches at end of subject string only */
|
||||||
|
|
||||||
#define AP_REG_NO_DOTALL 0x400 /**< remove AP_REG_DOTALL from defaults */
|
#define AP_REG_NO_DEFAULT 0x400 /**< Don't implicitely add AP_REG_DEFAULT options */
|
||||||
|
|
||||||
#define AP_REG_MATCH "MATCH_" /**< suggested prefix for ap_regname */
|
#define AP_REG_MATCH "MATCH_" /**< suggested prefix for ap_regname */
|
||||||
|
|
||||||
|
@ -716,8 +716,10 @@ static const char *set_pattern(cmd_parms *cmd, void *cfg, const char *line)
|
|||||||
|
|
||||||
/* first see if we can compile the regex */
|
/* first see if we can compile the regex */
|
||||||
if (!is_pattern) {
|
if (!is_pattern) {
|
||||||
r = ap_pregcomp(cmd->pool, from, AP_REG_NO_DOTALL | AP_REG_EXTENDED |
|
int flags = AP_REG_NO_DEFAULT
|
||||||
(ignore_case ? AP_REG_ICASE : 0));
|
| (ap_regcomp_get_default_cflags() & AP_REG_DOLLAR_ENDONLY)
|
||||||
|
| (ignore_case ? AP_REG_ICASE : 0);
|
||||||
|
r = ap_pregcomp(cmd->pool, from, flags);
|
||||||
if (!r)
|
if (!r)
|
||||||
return "Substitute could not compile regex";
|
return "Substitute could not compile regex";
|
||||||
}
|
}
|
||||||
|
@ -179,9 +179,6 @@ AP_DECLARE(int) ap_regcomp_default_cflag_by_name(const char *name)
|
|||||||
else if (ap_cstr_casecmp(name, "DOTALL") == 0) {
|
else if (ap_cstr_casecmp(name, "DOTALL") == 0) {
|
||||||
cflag = AP_REG_DOTALL;
|
cflag = AP_REG_DOTALL;
|
||||||
}
|
}
|
||||||
else if (ap_cstr_casecmp(name, "NO_DOTALL") == 0) {
|
|
||||||
cflag = AP_REG_NO_DOTALL;
|
|
||||||
}
|
|
||||||
else if (ap_cstr_casecmp(name, "DOLLAR_ENDONLY") == 0) {
|
else if (ap_cstr_casecmp(name, "DOLLAR_ENDONLY") == 0) {
|
||||||
cflag = AP_REG_DOLLAR_ENDONLY;
|
cflag = AP_REG_DOLLAR_ENDONLY;
|
||||||
}
|
}
|
||||||
@ -213,15 +210,15 @@ AP_DECLARE(int) ap_regcomp(ap_regex_t * preg, const char *pattern, int cflags)
|
|||||||
int errcode = 0;
|
int errcode = 0;
|
||||||
int options = PCREn(DUPNAMES);
|
int options = PCREn(DUPNAMES);
|
||||||
|
|
||||||
|
if ((cflags & AP_REG_NO_DEFAULT) == 0)
|
||||||
cflags |= default_cflags;
|
cflags |= default_cflags;
|
||||||
|
|
||||||
if ((cflags & AP_REG_ICASE) != 0)
|
if ((cflags & AP_REG_ICASE) != 0)
|
||||||
options |= PCREn(CASELESS);
|
options |= PCREn(CASELESS);
|
||||||
if ((cflags & AP_REG_NEWLINE) != 0)
|
if ((cflags & AP_REG_NEWLINE) != 0)
|
||||||
options |= PCREn(MULTILINE);
|
options |= PCREn(MULTILINE);
|
||||||
if ((cflags & AP_REG_DOTALL) != 0)
|
if ((cflags & AP_REG_DOTALL) != 0)
|
||||||
options |= PCREn(DOTALL);
|
options |= PCREn(DOTALL);
|
||||||
if ((cflags & AP_REG_NO_DOTALL) != 0)
|
|
||||||
options &= ~PCREn(DOTALL);
|
|
||||||
if ((cflags & AP_REG_DOLLAR_ENDONLY) != 0)
|
if ((cflags & AP_REG_DOLLAR_ENDONLY) != 0)
|
||||||
options |= PCREn(DOLLAR_ENDONLY);
|
options |= PCREn(DOLLAR_ENDONLY);
|
||||||
|
|
||||||
|
@ -94,6 +94,7 @@ AP_DECLARE(ap_rxplus_t*) ap_rxplus_compile(apr_pool_t *pool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* anything after the current delimiter is flags */
|
/* anything after the current delimiter is flags */
|
||||||
|
ret->flags = ap_regcomp_get_default_cflags() & AP_REG_DOLLAR_ENDONLY;
|
||||||
while (*++endp) {
|
while (*++endp) {
|
||||||
switch (*endp) {
|
switch (*endp) {
|
||||||
case 'i': ret->flags |= AP_REG_ICASE; break;
|
case 'i': ret->flags |= AP_REG_ICASE; break;
|
||||||
@ -101,13 +102,12 @@ AP_DECLARE(ap_rxplus_t*) ap_rxplus_compile(apr_pool_t *pool,
|
|||||||
case 'n': ret->flags |= AP_REG_NOMEM; break;
|
case 'n': ret->flags |= AP_REG_NOMEM; break;
|
||||||
case 'g': ret->flags |= AP_REG_MULTI; break;
|
case 'g': ret->flags |= AP_REG_MULTI; break;
|
||||||
case 's': ret->flags |= AP_REG_DOTALL; break;
|
case 's': ret->flags |= AP_REG_DOTALL; break;
|
||||||
case 'S': ret->flags |= AP_REG_NO_DOTALL; break;
|
|
||||||
case '^': ret->flags |= AP_REG_NOTBOL; break;
|
case '^': ret->flags |= AP_REG_NOTBOL; break;
|
||||||
case '$': ret->flags |= AP_REG_NOTEOL; break;
|
case '$': ret->flags |= AP_REG_NOTEOL; break;
|
||||||
default: break; /* we should probably be stricter here */
|
default: break; /* we should probably be stricter here */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ap_regcomp(&ret->rx, rxstr, ret->flags) == 0) {
|
if (ap_regcomp(&ret->rx, rxstr, AP_REG_NO_DEFAULT | ret->flags) == 0) {
|
||||||
apr_pool_cleanup_register(pool, &ret->rx, rxplus_cleanup,
|
apr_pool_cleanup_register(pool, &ret->rx, rxplus_cleanup,
|
||||||
apr_pool_cleanup_null);
|
apr_pool_cleanup_null);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user