yaoweibin / ngx_http_substitutions_filter_module

a filter module which can do both regular expression and fixed string substitutions for nginx
607 stars 213 forks source link

PCRE2 support in newest nginx mainline announced #41

Closed shmux8 closed 1 year ago

shmux8 commented 2 years ago

Hi,

Currently nginx can be built with PCRE2 support instead of unmaintained PCRE, but module does not have PCRE2 support. This simple patch helps:

diff --git a/ngx_http_subs_filter_module.c b/ngx_http_subs_filter_module.c
index bb48e9d..13355bf 100644
--- a/ngx_http_subs_filter_module.c
+++ b/ngx_http_subs_filter_module.c
@@ -1248,7 +1248,9 @@ ngx_http_subs_regex_capture_count(ngx_regex_t *re)

     n = 0;

-#if defined(nginx_version) && nginx_version >= 1002002
+#if (NGX_PCRE2)
+    rc = pcre2_pattern_info(re, PCRE2_INFO_CAPTURECOUNT, &n);
+#elif defined(nginx_version) && nginx_version >= 1002002
     rc = pcre_fullinfo(re->code, NULL, PCRE_INFO_CAPTURECOUNT, &n);
 #elif defined(nginx_version) && nginx_version >= 1001012
     rc = pcre_fullinfo(re->pcre, NULL, PCRE_INFO_CAPTURECOUNT, &n);
cuber commented 2 years ago

@shmux8 Great, could you make a pull request for this patch?

yaoweibin commented 2 years ago

Thank you @shmux8, your patch has been merged.

Cube @.***> 于2021年12月28日周二 11:43写道:

@shmux8 https://github.com/shmux8 Great, could you make a pull request for this patch?

— Reply to this email directly, view it on GitHub https://github.com/yaoweibin/ngx_http_substitutions_filter_module/issues/41#issuecomment-1001852867, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABFRGKGQNSO6UKJ67YC5ODUTEW6VANCNFSM5K2QGQLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: <yaoweibin/ngx_http_substitutions_filter_module/issues/41/1001852867@ github.com>

saidu941 commented 1 year ago

Updating the nginx version to 1.19.8 compiled for me