diff --git a/.requirements b/.requirements index 1b97894f7d26..4dcc4172e79d 100644 --- a/.requirements +++ b/.requirements @@ -3,7 +3,7 @@ KONG_PACKAGE_NAME=kong OPENRESTY=1.25.3.1 LUAROCKS=3.9.2 OPENSSL=3.2.0 -PCRE=8.45 +PCRE=10.42 LIBEXPAT=2.5.0 LUA_KONG_NGINX_MODULE=4fbc3ddc7dcbc706ed286b95344f3cb6da17e637 # 0.8.0 diff --git a/build/dockerfiles/apk.Dockerfile b/build/dockerfiles/apk.Dockerfile index bea623c9cdd2..fb3901a62d35 100644 --- a/build/dockerfiles/apk.Dockerfile +++ b/build/dockerfiles/apk.Dockerfile @@ -20,7 +20,7 @@ COPY ${KONG_ARTIFACT_PATH}${KONG_ARTIFACT} /tmp/kong.apk.tar.gz RUN apk upgrade --update-cache \ && apk add --virtual .build-deps tar gzip \ && tar -C / -xzf /tmp/kong.apk.tar.gz \ - && apk add --no-cache libstdc++ libgcc pcre perl tzdata libcap zlib zlib-dev bash yaml \ + && apk add --no-cache libstdc++ libgcc perl tzdata libcap zlib zlib-dev bash yaml \ && adduser -S kong \ && addgroup -S kong \ && mkdir -p "${KONG_PREFIX}" \ diff --git a/build/openresty/patches/openresty_02-pcre2.patch b/build/openresty/patches/openresty_02-pcre2.patch new file mode 100644 index 000000000000..b3146a4c57fc --- /dev/null +++ b/build/openresty/patches/openresty_02-pcre2.patch @@ -0,0 +1,14 @@ +diff --git a/configure b/configure +index 969b075..23322a9 100755 +--- a/configure ++++ b/configure +@@ -557,9 +557,6 @@ _END_ + "\n"; + } + +- # disable pcre2 by default +- push @ngx_opts, '--without-pcre2'; +- + if (!$opts->{no_stream} + && ! $opts->{no_stream_ssl} + && ! $opts->{stream_ssl}) diff --git a/build/openresty/pcre/BUILD.pcre.bazel b/build/openresty/pcre/BUILD.pcre.bazel index 229005a870f3..6e9658d93715 100644 --- a/build/openresty/pcre/BUILD.pcre.bazel +++ b/build/openresty/pcre/BUILD.pcre.bazel @@ -18,12 +18,12 @@ cmake( ], cache_entries = { "CMAKE_C_FLAGS": "${CMAKE_C_FLAGS:-} -fPIC", - "PCRE_BUILD_PCREGREP": "OFF", # we don't need the cli binary - "PCRE_BUILD_TESTS": "OFF", # test doesn't compile on aarch64-linux-gnu (cross) + "PCRE2_BUILD_PCRE2GREP": "OFF", # we don't need the cli binary + "PCRE2_BUILD_TESTS": "OFF", # test doesn't compile on aarch64-linux-gnu (cross) "CMAKE_INSTALL_LIBDIR": "lib", # force distros that uses lib64 (rhel family) to use lib }, lib_source = ":all_srcs", - out_static_libs = ["libpcre.a"], + out_static_libs = ["libpcre2-8.a"], visibility = ["//visibility:public"], ) diff --git a/build/openresty/pcre/pcre_repositories.bzl b/build/openresty/pcre/pcre_repositories.bzl index 54448927f566..bb593ffc7ad2 100644 --- a/build/openresty/pcre/pcre_repositories.bzl +++ b/build/openresty/pcre/pcre_repositories.bzl @@ -11,10 +11,9 @@ def pcre_repositories(): http_archive, name = "pcre", build_file = "//build/openresty/pcre:BUILD.pcre.bazel", - strip_prefix = "pcre-" + version, - sha256 = "4e6ce03e0336e8b4a3d6c2b70b1c5e18590a5673a98186da90d4f33c23defc09", + strip_prefix = "pcre2-" + version, + sha256 = "c33b418e3b936ee3153de2c61cc638e7e4fe3156022a5c77d0711bcbb9d64f1f", urls = [ - "https://mirror.bazel.build/downloads.sourceforge.net/project/pcre/pcre/" + version + "/pcre-" + version + ".tar.gz", - "https://downloads.sourceforge.net/project/pcre/pcre/" + version + "/pcre-" + version + ".tar.gz", + "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-" + version + "/pcre2-" + version + ".tar.gz", ], ) diff --git a/changelog/unreleased/kong/bump-pcre.yml b/changelog/unreleased/kong/bump-pcre.yml new file mode 100644 index 000000000000..b397c5a153c1 --- /dev/null +++ b/changelog/unreleased/kong/bump-pcre.yml @@ -0,0 +1,3 @@ +message: "Bumped PCRE from the legacy libpcre 8.45 to libpcre2 10.42" +type: dependency +scope: Core diff --git a/kong/tools/uri.lua b/kong/tools/uri.lua index ecc599199ea4..0a0274c7dab4 100644 --- a/kong/tools/uri.lua +++ b/kong/tools/uri.lua @@ -38,7 +38,7 @@ do end -local ESCAPE_PATTERN = "[^!#$&'()*+,/:;=?@[\\]A-Z\\d-_.~%]" +local ESCAPE_PATTERN = "[^!#$&'()*+,/:;=?@[\\]A-Z\\d\\-_.~%]" local TMP_OUTPUT = require("table.new")(16, 0) local DOT = string_byte(".") diff --git a/scripts/explain_manifest/suites.py b/scripts/explain_manifest/suites.py index 413e92c06536..89fb06ecfe24 100644 --- a/scripts/explain_manifest/suites.py +++ b/scripts/explain_manifest/suites.py @@ -30,8 +30,11 @@ def common_suites(expect, libxcrypt_no_obsolete_api: bool = False): .has_ngx_http_request_t_DW.equals(True) expect("/usr/local/openresty/nginx/sbin/nginx", "nginx binary should link pcre statically") \ - .exported_symbols.contain("pcre_free") \ - .needed_libraries.do_not().contain_match("libpcre.so.+") + .exported_symbols.contain("pcre2_general_context_free_8") \ + .exported_symbols.do_not().contain("pcre_free") \ + .needed_libraries.do_not().contain_match("libpcre.so.+") \ + .needed_libraries.do_not().contain_match("libpcre.+.so.+") \ + .needed_libraries.do_not().contain_match("libpcre2\-(8|16|32).so.+") \ expect("/usr/local/openresty/nginx/sbin/nginx", "nginx should not be compiled with debug flag") \ .nginx_compile_flags.do_not().match("with\-debug") diff --git a/spec/01-unit/01-db/01-schema/06-routes_spec.lua b/spec/01-unit/01-db/01-schema/06-routes_spec.lua index c614a890ff86..e8b788818f89 100644 --- a/spec/01-unit/01-db/01-schema/06-routes_spec.lua +++ b/spec/01-unit/01-db/01-schema/06-routes_spec.lua @@ -295,7 +295,7 @@ describe("routes schema (flavor = traditional/traditional_compatible)", function local ok, err = Routes:validate(route) assert.falsy(ok) assert.equal(u([[invalid regex: '/users/(foo/profile' (PCRE returned: - pcre_compile() failed: missing ) in + pcre2_compile() failed: missing closing parenthesis in "/users/(foo/profile")]], true, true), err.paths[1]) end end) diff --git a/spec/01-unit/01-db/01-schema/11-declarative_config/04-on-the-fly-migration_spec.lua b/spec/01-unit/01-db/01-schema/11-declarative_config/04-on-the-fly-migration_spec.lua index f1ea778f90cf..7ceb873ebe5f 100644 --- a/spec/01-unit/01-db/01-schema/11-declarative_config/04-on-the-fly-migration_spec.lua +++ b/spec/01-unit/01-db/01-schema/11-declarative_config/04-on-the-fly-migration_spec.lua @@ -184,5 +184,5 @@ it("validation should happens after migration", function () assert.falsy(config_tbl) assert.matches("invalid regex:", err, nil, true) assert.matches("/regex.+(", err, nil, true) - assert.matches("missing )", err, nil, true) + assert.matches("missing closing parenthesis", err, nil, true) end)