mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Support for PCRE2
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* ModSecurity for Apache 2.x, http://www.modsecurity.org/
|
||||
* Copyright (c) 2004-2013 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
* Copyright (c) 2004-2022 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
@@ -386,7 +386,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
|
||||
case HASH_URL_HREF_HASH_RX:
|
||||
if(em[i]->type == HASH_URL_HREF_HASH_RX) {
|
||||
rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg);
|
||||
#ifdef WITH_PCRE2
|
||||
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
|
||||
#else
|
||||
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
|
||||
#endif
|
||||
msc_string *s = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string));
|
||||
|
||||
if (s == NULL) return -1;
|
||||
@@ -415,7 +419,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
|
||||
msr_log(msr, 4, "%s.", error_msg);
|
||||
return -1;
|
||||
}
|
||||
#ifdef WITH_PCRE2
|
||||
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
|
||||
#else
|
||||
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -441,7 +449,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
|
||||
case HASH_URL_FACTION_HASH_RX:
|
||||
if(em[i]->type == HASH_URL_FACTION_HASH_RX) {
|
||||
rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg);
|
||||
#ifdef WITH_PCRE2
|
||||
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
|
||||
#else
|
||||
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
|
||||
#endif
|
||||
msc_string *s = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string));
|
||||
|
||||
if (s == NULL) return -1;
|
||||
@@ -470,7 +482,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
|
||||
msr_log(msr, 4, "%s.", error_msg);
|
||||
return -1;
|
||||
}
|
||||
#ifdef WITH_PCRE2
|
||||
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
|
||||
#else
|
||||
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -496,7 +512,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
|
||||
case HASH_URL_LOCATION_HASH_RX:
|
||||
if(em[i]->type == HASH_URL_LOCATION_HASH_RX) {
|
||||
rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg);
|
||||
#ifdef WITH_PCRE2
|
||||
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
|
||||
#else
|
||||
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
|
||||
#endif
|
||||
msc_string *s = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string));
|
||||
|
||||
if (s == NULL) return -1;
|
||||
@@ -525,7 +545,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
|
||||
msr_log(msr, 4, "%s.", error_msg);
|
||||
return -1;
|
||||
}
|
||||
#ifdef WITH_PCRE2
|
||||
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
|
||||
#else
|
||||
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -551,7 +575,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
|
||||
case HASH_URL_IFRAMESRC_HASH_RX:
|
||||
if(em[i]->type == HASH_URL_IFRAMESRC_HASH_RX) {
|
||||
rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg);
|
||||
#ifdef WITH_PCRE2
|
||||
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
|
||||
#else
|
||||
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
|
||||
#endif
|
||||
msc_string *s = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string));
|
||||
|
||||
if (s == NULL) return -1;
|
||||
@@ -580,7 +608,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
|
||||
msr_log(msr, 4, "%s.", error_msg);
|
||||
return -1;
|
||||
}
|
||||
#ifdef WITH_PCRE2
|
||||
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
|
||||
#else
|
||||
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -606,7 +638,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
|
||||
case HASH_URL_FRAMESRC_HASH_RX:
|
||||
if(em[i]->type == HASH_URL_FRAMESRC_HASH_RX) {
|
||||
rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg);
|
||||
#ifdef WITH_PCRE2
|
||||
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
|
||||
#else
|
||||
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
|
||||
#endif
|
||||
msc_string *s = (msc_string *)apr_pcalloc(msr->mp, sizeof(msc_string));
|
||||
|
||||
if (s == NULL) return -1;
|
||||
@@ -635,7 +671,11 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
|
||||
msr_log(msr, 4, "%s.", error_msg);
|
||||
return -1;
|
||||
}
|
||||
#ifdef WITH_PCRE2
|
||||
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
|
||||
#else
|
||||
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user