diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2021-12-25 01:07:18 +0300 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2021-12-25 01:07:18 +0300 |
commit | d5f1f169bc71d32b96960266d54e189c69af00ba (patch) | |
tree | 7d0190e2d6e53af3944da7b25d3aa3d9d118b9de /src/core/ngx_regex.c | |
parent | 931acbf5bcd550af8613d131f4ba49e22e909efb (diff) | |
download | nginx-d5f1f169bc71d32b96960266d54e189c69af00ba.tar.gz nginx-d5f1f169bc71d32b96960266d54e189c69af00ba.zip |
Core: added NGX_REGEX_MULTILINE for 3rd party modules.
Notably, NAXSI is known to misuse ngx_regex_compile() with rc.options set
to PCRE_CASELESS | PCRE_MULTILINE. With PCRE2 support, and notably binary
compatibility changes, it is no longer possible to set PCRE[2]_MULTILINE
option without using proper interface. To facilitate correct usage,
this change adds the NGX_REGEX_MULTILINE option.
Diffstat (limited to 'src/core/ngx_regex.c')
-rw-r--r-- | src/core/ngx_regex.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/core/ngx_regex.c b/src/core/ngx_regex.c index 991728b27..bebf3b6a8 100644 --- a/src/core/ngx_regex.c +++ b/src/core/ngx_regex.c @@ -159,7 +159,11 @@ ngx_regex_compile(ngx_regex_compile_t *rc) options |= PCRE2_CASELESS; } - if (rc->options & ~NGX_REGEX_CASELESS) { + if (rc->options & NGX_REGEX_MULTILINE) { + options |= PCRE2_MULTILINE; + } + + if (rc->options & ~(NGX_REGEX_CASELESS|NGX_REGEX_MULTILINE)) { rc->err.len = ngx_snprintf(rc->err.data, rc->err.len, "regex \"%V\" compilation failed: invalid options", &rc->pattern) @@ -275,7 +279,11 @@ ngx_regex_compile(ngx_regex_compile_t *rc) options |= PCRE_CASELESS; } - if (rc->options & ~NGX_REGEX_CASELESS) { + if (rc->options & NGX_REGEX_MULTILINE) { + options |= PCRE_MULTILINE; + } + + if (rc->options & ~(NGX_REGEX_CASELESS|NGX_REGEX_MULTILINE)) { rc->err.len = ngx_snprintf(rc->err.data, rc->err.len, "regex \"%V\" compilation failed: invalid options", &rc->pattern) |