This is an automated email from the ASF dual-hosted git repository.
bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new b38147f370 Remove PCRE references, complete migration to PCRE2 (#12685)
b38147f370 is described below
commit b38147f37095f0bf6f7ebdfb449ea98b1ace0690
Author: Bryan Call <[email protected]>
AuthorDate: Mon Dec 1 09:22:17 2025 -0800
Remove PCRE references, complete migration to PCRE2 (#12685)
- Remove cmake/FindPCRE.cmake (no longer needed)
- Update all CMakeLists.txt files to use PkgConfig::PCRE2 instead of
PCRE::PCRE
- Remove find_package(PCRE) from main CMakeLists.txt
- Update code comments from PCRE to PCRE2 in plugin sources
- Update coverity model from PCRE to PCRE2 API
- Update README example to remove obsolete PCRE_ROOT reference
- Update tools/hrw4u/src/lsp/documentation.py to reference PCRE2
- Note: cripts::Matcher::PCRE class name intentionally unchanged (public
API)
- Remove redundant PCRE2 links, use tsutil Regex wrapper
- Use RE_ERROR_NOMATCH from tsutil instead of PCRE2_ERROR_NOMATCH in
ControlMatcher to properly use the Regex wrapper
- Remove direct pcre2.h include from ControlMatcher.h
- Remove redundant PCRE2 links from components that get it transitively
through tsutil (tscore, tsapi)
- Remove redundant PCRE2 links from plugins that only use tsutil/Regex.h
(cachekey, prefetch, slice, tls_bridge)
Only components that directly use PCRE2 APIs (tsutil, cripts, txn_box)
should explicitly link PCRE2. Others get it transitively through tsutil
which publicly exports PCRE2.
---
CMakeLists.txt | 1 -
README.md | 2 +-
ci/coverity-model.cpp | 16 +++-----
cmake/FindPCRE.cmake | 48 ----------------------
include/proxy/ControlMatcher.h | 3 --
plugins/cachekey/CMakeLists.txt | 4 +-
plugins/cachekey/cachekey.cc | 4 +-
plugins/cachekey/pattern.cc | 2 +-
plugins/cachekey/unit_tests/pattern_test.cc | 4 +-
plugins/experimental/access_control/pattern.cc | 32 +++++++--------
plugins/experimental/access_control/pattern.h | 6 +--
plugins/experimental/geoip_acl/README | 2 +-
plugins/experimental/memcache/CMakeLists.txt | 5 ++-
plugins/experimental/tls_bridge/CMakeLists.txt | 2 +-
plugins/experimental/tls_bridge/tls_bridge.cc | 2 +-
.../txn_box/plugin/include/txn_box/Context.h | 4 +-
.../txn_box/plugin/include/txn_box/Rxp.h | 2 +-
plugins/header_rewrite/CMakeLists.txt | 2 +-
plugins/lua/ts_lua_common.h | 2 +-
plugins/prefetch/CMakeLists.txt | 2 +-
plugins/prefetch/pattern.cc | 26 ++++++------
plugins/prefetch/pattern.h | 6 +--
plugins/slice/CMakeLists.txt | 2 +-
plugins/slice/unit-tests/CMakeLists.txt | 2 +-
src/api/CMakeLists.txt | 4 +-
src/cripts/Matcher.cc | 4 +-
src/proxy/ControlMatcher.cc | 8 ++--
src/proxy/hdrs/HdrToken.cc | 2 +-
src/tscore/CMakeLists.txt | 9 +---
tools/hrw4u/src/lsp/documentation.py | 20 ++++-----
30 files changed, 81 insertions(+), 147 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b44a3a9997..cf4473ec60 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -274,7 +274,6 @@ if(LibLZMA_FOUND)
set(HAVE_LZMA_H TRUE)
endif()
-find_package(PCRE REQUIRED)
pkg_check_modules(PCRE2 REQUIRED IMPORTED_TARGET libpcre2-8)
include(CheckOpenSSLIsBoringSSL)
diff --git a/README.md b/README.md
index 260aa42bd3..46d5eaf753 100644
--- a/README.md
+++ b/README.md
@@ -47,7 +47,7 @@ $ ccmake build
To specify the location of a dependency (like `--with-*` for autotools
builds), you generally set a variable with the `ROOT`. The big exception to
this is for openssl. This variable is called `OPENSSL_ROOT_DIR`
```
-$ cmake -B build -Djemalloc_ROOT=/opt/jemalloc -DPCRE_ROOT=/opt/edge
-DOPENSSL_ROOT_DIR=/opt/boringssl
+$ cmake -B build -Djemalloc_ROOT=/opt/jemalloc
-DOPENSSL_ROOT_DIR=/opt/boringssl
```
#### Using presets to configure the build
diff --git a/ci/coverity-model.cpp b/ci/coverity-model.cpp
index 02f2ed777f..1f8ea14ccb 100644
--- a/ci/coverity-model.cpp
+++ b/ci/coverity-model.cpp
@@ -16,21 +16,15 @@
limitations under the License.
*/
-// This is for PCRE, where the offsets vector is considered uninitialized, but
it's an
+// This is for PCRE2, where the offsets vector is considered uninitialized,
but it's an
// output vector only (input doesn't matter).
extern "C" {
-#define PCRE_SPTR const char *
-
-struct real_pcre; /* declaration; the definition is private */
-typedef struct real_pcre pcre;
-
-typedef struct pcre_extra {
-} pcre_extra;
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
int
-pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,
- PCRE_SPTR subject, int length, int start_offset, int options, int
*offsets,
- int offsetcount)
+pcre2_match(const pcre2_code *code, PCRE2_SPTR subject, PCRE2_SIZE length,
PCRE2_SIZE startoffset, uint32_t options,
+ pcre2_match_data *match_data, pcre2_match_context *mcontext)
{
__coverity_panic__();
}
diff --git a/cmake/FindPCRE.cmake b/cmake/FindPCRE.cmake
deleted file mode 100644
index 627e1c990b..0000000000
--- a/cmake/FindPCRE.cmake
+++ /dev/null
@@ -1,48 +0,0 @@
-#######################
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
-# agreements. See the NOTICE file distributed with this work for additional
information regarding
-# copyright ownership. The ASF licenses this file to you under the Apache
License, Version 2.0
-# (the "License"); you may not use this file except in compliance with the
License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
distributed under the License
-# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express
-# or implied. See the License for the specific language governing permissions
and limitations under
-# the License.
-#
-#######################
-
-# FindPCRE.cmake
-#
-# This will define the following variables
-#
-# PCRE_FOUND
-# PCRE_LIBRARIES
-# PCRE_INCLUDE_DIRS
-#
-# and the following imported targets
-#
-# PCRE::PCRE
-#
-
-find_path(PCRE_INCLUDE_DIR NAMES pcre.h) # PATH_SUFFIXES pcre)
-find_library(PCRE_LIBRARY NAMES pcre)
-
-mark_as_advanced(PCRE_FOUND PCRE_LIBRARY PCRE_INCLUDE_DIR)
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(PCRE REQUIRED_VARS PCRE_INCLUDE_DIR
PCRE_LIBRARY)
-
-if(PCRE_FOUND)
- set(PCRE_INCLUDE_DIRS "${PCRE_INCLUDE_DIR}")
- set(PCRE_LIBRARIES "${PCRE_LIBRARY}")
-endif()
-
-if(PCRE_FOUND AND NOT TARGET PCRE::PCRE)
- add_library(PCRE::PCRE INTERFACE IMPORTED)
- target_include_directories(PCRE::PCRE INTERFACE ${PCRE_INCLUDE_DIRS})
- target_link_libraries(PCRE::PCRE INTERFACE "${PCRE_LIBRARY}")
-endif()
diff --git a/include/proxy/ControlMatcher.h b/include/proxy/ControlMatcher.h
index d2f34ee031..96e9c36e96 100644
--- a/include/proxy/ControlMatcher.h
+++ b/include/proxy/ControlMatcher.h
@@ -97,9 +97,6 @@
#include "tsutil/Regex.h"
#include "proxy/hdrs/URL.h"
-#define PCRE2_CODE_UNIT_WIDTH 8
-#include "pcre2.h"
-
#include <swoc/swoc_ip.h>
#ifdef HAVE_CTYPE_H
diff --git a/plugins/cachekey/CMakeLists.txt b/plugins/cachekey/CMakeLists.txt
index f88a89db18..65c506c352 100644
--- a/plugins/cachekey/CMakeLists.txt
+++ b/plugins/cachekey/CMakeLists.txt
@@ -16,8 +16,6 @@
#######################
add_atsplugin(cachekey cachekey.cc common.cc configs.cc pattern.cc plugin.cc)
-
-target_link_libraries(cachekey PRIVATE PCRE::PCRE)
verify_global_plugin(cachekey)
verify_remap_plugin(cachekey)
@@ -26,6 +24,6 @@ if(BUILD_TESTING)
add_executable(pattern_test unit_tests/pattern_test.cc pattern.cc common.cc)
target_include_directories(pattern_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(pattern_test PRIVATE CACHEKEY_UNIT_TEST)
- target_link_libraries(pattern_test PRIVATE Catch2::Catch2WithMain PCRE::PCRE
libswoc::libswoc ts::tsutil)
+ target_link_libraries(pattern_test PRIVATE Catch2::Catch2WithMain
libswoc::libswoc ts::tsutil)
add_catch2_test(NAME pattern_test COMMAND pattern_test)
endif()
diff --git a/plugins/cachekey/cachekey.cc b/plugins/cachekey/cachekey.cc
index 71930ef048..6bc838aec4 100644
--- a/plugins/cachekey/cachekey.cc
+++ b/plugins/cachekey/cachekey.cc
@@ -676,8 +676,8 @@ CacheKey::appendQuery(const ConfigQuery &config)
/**
* @brief Append User-Agent header captures specified in the Pattern
configuration object.
*
- * Apply given PCRE pattern/replacement to the first User-Agent value, and
append any captured portions to cache key.
- * @param config PCRE pattern which contains capture groups.
+ * Apply given PCRE2 pattern/replacement to the first User-Agent value, and
append any captured portions to cache key.
+ * @param config PCRE2 pattern which contains capture groups.
* @todo: TBD if ignoring the comma in the header as a field separator is
generic enough.
* @note Add the UA captures to hier-part (RFC 3986) in the original order.
*/
diff --git a/plugins/cachekey/pattern.cc b/plugins/cachekey/pattern.cc
index e871e15f03..515cd8f4f0 100644
--- a/plugins/cachekey/pattern.cc
+++ b/plugins/cachekey/pattern.cc
@@ -134,7 +134,7 @@ Pattern::empty() const
* @brief Capture or capture-and-replace depending on whether a replacement
string is specified.
* @see replace()
* @see capture()
- * @param subject PCRE subject string
+ * @param subject PCRE2 subject string
* @param result vector of strings where the result of captures or the
replacements will be returned.
* @return true if there was a match and capture or replacement succeeded,
false if failure.
*/
diff --git a/plugins/cachekey/unit_tests/pattern_test.cc
b/plugins/cachekey/unit_tests/pattern_test.cc
index 77f8bdb325..2b9adb90d4 100644
--- a/plugins/cachekey/unit_tests/pattern_test.cc
+++ b/plugins/cachekey/unit_tests/pattern_test.cc
@@ -83,7 +83,7 @@ TEST_CASE("Pattern compile and match behavior",
"[cachekey][pattern]")
{
Pattern p;
REQUIRE(p.init("^$"));
- // Pattern::match uses PCRE_NOTEMPTY which prevents empty-string matches.
+ // Pattern::match uses PCRE2_NOTEMPTY which prevents empty-string matches.
// Therefore '^$' will NOT match an empty subject with the current
implementation.
CHECK(p.match("") == false);
CHECK(p.match("not-empty") == false);
@@ -92,7 +92,7 @@ TEST_CASE("Pattern compile and match behavior",
"[cachekey][pattern]")
SECTION("Case-insensitive inline flag")
{
Pattern p;
- // PCRE inline flag for case-insensitive
+ // PCRE2 inline flag for case-insensitive
REQUIRE(p.init("(?i)AbC"));
CHECK(p.match("aBc") == true);
CHECK(p.match("ABC") == true);
diff --git a/plugins/experimental/access_control/pattern.cc
b/plugins/experimental/access_control/pattern.cc
index 179131653a..a1153e6a2d 100644
--- a/plugins/experimental/access_control/pattern.cc
+++ b/plugins/experimental/access_control/pattern.cc
@@ -45,9 +45,9 @@ Pattern::Pattern() : _pattern(""), _replacement("") {}
Pattern::~Pattern() = default;
/**
- * @brief Initializes PCRE pattern by providing the subject and replacement
strings.
- * @param pattern PCRE pattern, a string containing PCRE patterns, capturing
groups.
- * @param replacement PCRE replacement, a string where $0 ... $9 will be
replaced with the corresponding capturing groups
+ * @brief Initializes PCRE2 pattern by providing the subject and replacement
strings.
+ * @param pattern PCRE2 pattern, a string containing PCRE2 patterns, capturing
groups.
+ * @param replacement PCRE2 replacement, a string where $0 ... $9 will be
replaced with the corresponding capturing groups
* @return true if successful, false if failure
*/
bool
@@ -69,9 +69,9 @@ Pattern::init(const String &pattern, const String
&replacement, bool replace)
}
/**
- * @brief Initializes PCRE pattern by providing the pattern only or
pattern+replacement in a single configuration string.
+ * @brief Initializes PCRE2 pattern by providing the pattern only or
pattern+replacement in a single configuration string.
* @see init()
- * @param config PCRE pattern <pattern> or PCRE pattern + replacement in
format /<pattern>/<replacement>/
+ * @param config PCRE2 pattern <pattern> or PCRE2 pattern + replacement in
format /<pattern>/<replacement>/
* @return true if successful, false if failure
*/
bool
@@ -145,14 +145,14 @@ Pattern::empty() const
}
/**
- * @brief Destructor, frees PCRE related resources.
+ * @brief Destructor, frees PCRE2 related resources.
*/
/**
* @brief Capture or capture-and-replace depending on whether a replacement
string is specified.
* @see replace()
* @see capture()
- * @param subject PCRE subject string
+ * @param subject PCRE2 subject string
* @param result vector of strings where the result of captures or the
replacements will be returned.
* @return true if there was a match and capture or replacement succeeded,
false if failure.
*/
@@ -188,8 +188,8 @@ Pattern::process(const String &subject, StringVector
&result)
}
/**
- * @brief PCRE matches a subject string against the regex pattern.
- * @param subject PCRE subject
+ * @brief PCRE2 matches a subject string against the regex pattern.
+ * @param subject PCRE2 subject
* @return true - matched, false - did not.
*/
bool
@@ -214,8 +214,8 @@ Pattern::match(const String &subject)
}
/**
- * @brief Return all PCRE capture groups that matched in the subject string
- * @param subject PCRE subject string
+ * @brief Return all PCRE2 capture groups that matched in the subject string
+ * @param subject PCRE2 subject string
* @param result reference to vector of strings containing all capture groups
*/
bool
@@ -249,8 +249,8 @@ Pattern::capture(const String &subject, StringVector
&result)
}
/**
- * @brief Replaces all replacements found in the replacement string with what
matched in the PCRE capturing groups.
- * @param subject PCRE subject string
+ * @brief Replaces all replacements found in the replacement string with what
matched in the PCRE2 capturing groups.
+ * @param subject PCRE2 subject string
* @param result reference to A string where the result of the replacement
will be stored
* @return true - success, false - nothing matched or failure.
*/
@@ -305,14 +305,14 @@ Pattern::replace(const String &subject, String &result)
}
/**
- * @brief PCRE compiles the regex, called only during initialization.
+ * @brief PCRE2 compiles the regex, called only during initialization.
* @return true if successful, false if not.
*/
bool
Pattern::compile()
{
- std::string error; /* PCRE error description */
- int errOffset; /* PCRE error offset */
+ std::string error; /* PCRE2 error description */
+ int errOffset; /* PCRE2 error offset */
AccessControlDebug("compiling pattern:'%s', replace: %s, replacement:'%s'",
_pattern.c_str(), _replace ? "true" : "false",
_replacement.c_str());
diff --git a/plugins/experimental/access_control/pattern.h
b/plugins/experimental/access_control/pattern.h
index 4dc28f97b8..1651fdabe8 100644
--- a/plugins/experimental/access_control/pattern.h
+++ b/plugins/experimental/access_control/pattern.h
@@ -28,7 +28,7 @@
class Regex;
/**
- * @brief PCRE matching, capturing and replacing
+ * @brief PCRE2 matching, capturing and replacing
*/
class Pattern
{
@@ -52,8 +52,8 @@ private:
std::unique_ptr<Regex> _re; /**< @brief Regex compiled object, computed
during initialization */
- String _pattern; /**< @brief PCRE pattern string, containing PCRE
patterns and capturing groups. */
- String _replacement; /**< @brief PCRE replacement string, containing $0..$9
to be replaced with content of the capturing groups */
+ String _pattern; /**< @brief PCRE2 pattern string, containing PCRE2
patterns and capturing groups. */
+ String _replacement; /**< @brief PCRE2 replacement string with $0..$9
placeholders for capturing groups */
bool _replace = false; /**< @brief true if a replacement is needed, false if
not, this is to distinguish between an empty
replacement string and no replacement needed case */
diff --git a/plugins/experimental/geoip_acl/README
b/plugins/experimental/geoip_acl/README
index 3e4864d03a..e36a931c7c 100644
--- a/plugins/experimental/geoip_acl/README
+++ b/plugins/experimental/geoip_acl/README
@@ -48,7 +48,7 @@ separate regex mapping filter. The remap.config file might
then look like
@plugin=geoip_acl.so @pparam=country @pparam=regex::/etc/music.regex
-where music.regex is a format with PCRE (perl compatible) regular
+where music.regex is a format with PCRE2 (perl compatible) regular
expressions, and unique rules for match. E.g.
.*\.mp3 allow US
diff --git a/plugins/experimental/memcache/CMakeLists.txt
b/plugins/experimental/memcache/CMakeLists.txt
index 2602bd1685..521ec69d6f 100644
--- a/plugins/experimental/memcache/CMakeLists.txt
+++ b/plugins/experimental/memcache/CMakeLists.txt
@@ -21,8 +21,9 @@ get_target_property(EVENT_INCLUDES ts::inkevent
INCLUDE_DIRECTORIES)
get_target_property(NET_INCLUDES ts::inknet INCLUDE_DIRECTORIES)
target_include_directories(
- memcache PRIVATE $<TARGET_PROPERTY:ts::inkevent,INCLUDE_DIRECTORIES>
- $<TARGET_PROPERTY:ts::inknet,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:PCRE::PCRE,INCLUDE_DIRECTORIES>
+ memcache
+ PRIVATE $<TARGET_PROPERTY:ts::inkevent,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:ts::inknet,INCLUDE_DIRECTORIES>
+ $<TARGET_PROPERTY:PkgConfig::PCRE2,INCLUDE_DIRECTORIES>
)
# This fails on OSX for this symbol: VConnection::set_continuation(VIO *,
Continuation *)
#verify_global_plugin(memcache)
diff --git a/plugins/experimental/tls_bridge/CMakeLists.txt
b/plugins/experimental/tls_bridge/CMakeLists.txt
index bb13df997e..375ed06672 100644
--- a/plugins/experimental/tls_bridge/CMakeLists.txt
+++ b/plugins/experimental/tls_bridge/CMakeLists.txt
@@ -17,6 +17,6 @@
add_atsplugin(tls_bridge tls_bridge.cc)
-target_link_libraries(tls_bridge PRIVATE libswoc::libswoc PCRE::PCRE #
transitive
+target_link_libraries(tls_bridge PRIVATE libswoc::libswoc # transitive
)
verify_global_plugin(tls_bridge)
diff --git a/plugins/experimental/tls_bridge/tls_bridge.cc
b/plugins/experimental/tls_bridge/tls_bridge.cc
index 37dfdc0f36..702ff40600 100644
--- a/plugins/experimental/tls_bridge/tls_bridge.cc
+++ b/plugins/experimental/tls_bridge/tls_bridge.cc
@@ -114,7 +114,7 @@ void
BridgeConfig::load_pair(std::string_view rxp, std::string_view service,
swoc::file::path const &src, int ln)
{
Regex r;
- // Unfortunately PCRE can only compile null terminated strings...
+ // Unfortunately PCRE2 can only compile null terminated strings...
std::string pattern{rxp};
if (r.compile(pattern.c_str(), REFlags::RE_ANCHORED)) {
_items.emplace_back(rxp, std::move(r), service);
diff --git a/plugins/experimental/txn_box/plugin/include/txn_box/Context.h
b/plugins/experimental/txn_box/plugin/include/txn_box/Context.h
index 48c851fff7..8f7a2c84b7 100644
--- a/plugins/experimental/txn_box/plugin/include/txn_box/Context.h
+++ b/plugins/experimental/txn_box/plugin/include/txn_box/Context.h
@@ -299,7 +299,7 @@ public:
/// Should the active feature be updated (e.g., is used later).
bool _update_remainder_p = false;
- /// Context for working with PCRE - allocates from the transaction arena.
+ /// Context for working with PCRE2 - allocates from the transaction arena.
pcre2_general_context *_rxp_ctx = nullptr;
/** Set capture groups for a literal match.
@@ -428,7 +428,7 @@ public:
/// Value to return from a remap invocation.
TSRemapStatus _remap_status = TSREMAP_NO_REMAP;
- /** Working match data for doing PCRE matching.
+ /** Working match data for doing PCRE2 matching.
*
* @param n Number of capture groups required.
* @return Cpature data sufficient to match @a n groups.
diff --git a/plugins/experimental/txn_box/plugin/include/txn_box/Rxp.h
b/plugins/experimental/txn_box/plugin/include/txn_box/Rxp.h
index a9a15cc878..562e3e16f5 100644
--- a/plugins/experimental/txn_box/plugin/include/txn_box/Rxp.h
+++ b/plugins/experimental/txn_box/plugin/include/txn_box/Rxp.h
@@ -39,7 +39,7 @@
/** Regular expression support.
*
* This is split out from @c Comparison because regular expressions will be
used in additional
- * situations. It is non-copyable because it is basically a wrapper on a
non-shared PCRE code
+ * situations. It is non-copyable because it is basically a wrapper on a
non-shared PCRE2 code
* block and it seems silly to have a handle to what is effectively a handle.
Aggregrating classes
* can deal with it the same way as a @c std::unique_ptr.
*/
diff --git a/plugins/header_rewrite/CMakeLists.txt
b/plugins/header_rewrite/CMakeLists.txt
index edac68608a..4c658b78ba 100644
--- a/plugins/header_rewrite/CMakeLists.txt
+++ b/plugins/header_rewrite/CMakeLists.txt
@@ -67,7 +67,7 @@ if(BUILD_TESTING)
# add_executable(test_matcher matcher_tests.cc matcher.cc lulu.cc
regex_helper.cc resources.cc)
# add_catch2_test(NAME test_matcher COMMAND $<TARGET_FILE:test_matcher>)
#
- # target_link_libraries(test_matcher PRIVATE Catch2::Catch2WithMain
ts::tscore libswoc::libswoc PCRE::PCRE)
+ # target_link_libraries(test_matcher PRIVATE Catch2::Catch2WithMain
ts::tscore libswoc::libswoc PkgConfig::PCRE2)
endif()
verify_global_plugin(header_rewrite)
diff --git a/plugins/lua/ts_lua_common.h b/plugins/lua/ts_lua_common.h
index 10b38fbde0..17e554893f 100644
--- a/plugins/lua/ts_lua_common.h
+++ b/plugins/lua/ts_lua_common.h
@@ -72,7 +72,7 @@ extern "C" {
#define TS_LUA_MAX_SHARED_DICT_COUNT 32
#define TS_LUA_MAX_URL_LENGTH 32768
#define TS_LUA_MAX_OVEC_SIZE (3 * 32)
-#define TS_LUA_MAX_RESIDENT_PCRE 64
+#define TS_LUA_MAX_RESIDENT_PCRE2 64
#define TS_LUA_MAX_STR_LENGTH 32768
#define TS_LUA_MIN_ALIGN sizeof(void *)
diff --git a/plugins/prefetch/CMakeLists.txt b/plugins/prefetch/CMakeLists.txt
index 432538f74f..28637b6f17 100644
--- a/plugins/prefetch/CMakeLists.txt
+++ b/plugins/prefetch/CMakeLists.txt
@@ -31,7 +31,7 @@ add_atsplugin(
plugin.cc
)
-target_link_libraries(prefetch PRIVATE OpenSSL::Crypto PCRE::PCRE)
+target_link_libraries(prefetch PRIVATE OpenSSL::Crypto)
verify_remap_plugin(prefetch)
diff --git a/plugins/prefetch/pattern.cc b/plugins/prefetch/pattern.cc
index a03460ec86..22926c42f4 100644
--- a/plugins/prefetch/pattern.cc
+++ b/plugins/prefetch/pattern.cc
@@ -42,9 +42,9 @@ replaceString(String &str, const String &from, const String
&to)
Pattern::Pattern() : _pattern(""), _replacement("") {}
/**
- * @brief Initializes PCRE pattern by providing the subject and replacement
strings.
- * @param pattern PCRE pattern, a string containing PCRE patterns, capturing
groups.
- * @param replacement PCRE replacement, a string where $0 ... $9 will be
replaced with the corresponding capturing groups
+ * @brief Initializes PCRE2 pattern by providing the subject and replacement
strings.
+ * @param pattern PCRE2 pattern, a string containing PCRE2 patterns, capturing
groups.
+ * @param replacement PCRE2 replacement, a string where $0 ... $9 will be
replaced with the corresponding capturing groups
* @return true if successful, false if failure
*/
bool
@@ -64,9 +64,9 @@ Pattern::init(const String &pattern, const String
&replacement)
}
/**
- * @brief Initializes PCRE pattern by providing the pattern only or
pattern+replacement in a single configuration string.
+ * @brief Initializes PCRE2 pattern by providing the pattern only or
pattern+replacement in a single configuration string.
* @see init()
- * @param config PCRE pattern <pattern> or PCRE pattern + replacement in
format /<pattern>/<replacement>/
+ * @param config PCRE2 pattern <pattern> or PCRE2 pattern + replacement in
format /<pattern>/<replacement>/
* @return true if successful, false if failure
*/
bool
@@ -134,7 +134,7 @@ Pattern::empty() const
* @brief Capture or capture-and-replace depending on whether a replacement
string is specified.
* @see replace()
* @see capture()
- * @param subject PCRE subject string
+ * @param subject PCRE2 subject string
* @param result vector of strings where the result of captures or the
replacements will be returned.
* @return true if there was a match and capture or replacement succeeded,
false if failure.
*/
@@ -170,8 +170,8 @@ Pattern::process(const String &subject, StringVector
&result)
}
/**
- * @brief PCRE matches a subject string against the regex pattern.
- * @param subject PCRE subject
+ * @brief PCRE2 matches a subject string against the regex pattern.
+ * @param subject PCRE2 subject
* @return true - matched, false - did not.
*/
bool
@@ -196,8 +196,8 @@ Pattern::match(const String &subject)
}
/**
- * @brief Return all PCRE capture groups that matched in the subject string
- * @param subject PCRE subject string
+ * @brief Return all PCRE2 capture groups that matched in the subject string
+ * @param subject PCRE2 subject string
* @param result reference to vector of strings containing all capture groups
*/
bool
@@ -229,8 +229,8 @@ Pattern::capture(const String &subject, StringVector
&result)
}
/**
- * @brief Replaces all replacements found in the replacement string with what
matched in the PCRE capturing groups.
- * @param subject PCRE subject string
+ * @brief Replaces all replacements found in the replacement string with what
matched in the PCRE2 capturing groups.
+ * @param subject PCRE2 subject string
* @param result reference to A string where the result of the replacement
will be stored
* @return true - success, false - nothing matched or failure.
*/
@@ -284,7 +284,7 @@ Pattern::replace(const String &subject, String &result)
}
/**
- * @brief PCRE compiles the regex, called only during initialization.
+ * @brief PCRE2 compiles the regex, called only during initialization.
* @return true if successful, false if not.
*/
bool
diff --git a/plugins/prefetch/pattern.h b/plugins/prefetch/pattern.h
index 1432cfbbfe..1105c17305 100644
--- a/plugins/prefetch/pattern.h
+++ b/plugins/prefetch/pattern.h
@@ -27,7 +27,7 @@
#include "tsutil/Regex.h"
/**
- * @brief PCRE matching, capturing and replacing
+ * @brief PCRE2 matching, capturing and replacing
*/
class Pattern
{
@@ -50,8 +50,8 @@ private:
Regex _regex;
- String _pattern; /**< @brief PCRE pattern string, containing PCRE
patterns and capturing groups. */
- String _replacement; /**< @brief PCRE replacement string, containing $0..$9
to be replaced with content of the capturing groups */
+ String _pattern; /**< @brief PCRE2 pattern string, containing PCRE2
patterns and capturing groups. */
+ String _replacement; /**< @brief PCRE2 replacement string with $0..$9
placeholders for capturing groups */
int _tokenCount = 0; /**< @brief number of replacements $0..$9
found in the replacement string if not empty */
int _tokens[TOKENCOUNT]; /**< @brief replacement index 0..9, since they
can be used in the replacement string in any order */
diff --git a/plugins/slice/CMakeLists.txt b/plugins/slice/CMakeLists.txt
index 8303b83c71..82bb4356e9 100644
--- a/plugins/slice/CMakeLists.txt
+++ b/plugins/slice/CMakeLists.txt
@@ -34,7 +34,7 @@ add_atsplugin(
ObjectSizeCache.cc
)
-target_link_libraries(slice PRIVATE PCRE::PCRE libswoc::libswoc)
+target_link_libraries(slice PRIVATE libswoc::libswoc)
if(BUILD_TESTING)
add_subdirectory(unit-tests)
endif()
diff --git a/plugins/slice/unit-tests/CMakeLists.txt
b/plugins/slice/unit-tests/CMakeLists.txt
index 6883fc766b..e50cb0e7e2 100644
--- a/plugins/slice/unit-tests/CMakeLists.txt
+++ b/plugins/slice/unit-tests/CMakeLists.txt
@@ -27,7 +27,7 @@ add_catch2_test(NAME test_range COMMAND test_range)
add_executable(test_config test_config.cc ${PROJECT_SOURCE_DIR}/Config.cc
${PROJECT_SOURCE_DIR}/ObjectSizeCache.cc)
target_compile_definitions(test_config PRIVATE UNITTEST)
-target_link_libraries(test_config PRIVATE PCRE::PCRE Catch2::Catch2WithMain
ts::tsutil)
+target_link_libraries(test_config PRIVATE Catch2::Catch2WithMain ts::tsutil)
add_catch2_test(NAME test_config COMMAND test_config)
add_executable(test_cache test_cache.cc
${PROJECT_SOURCE_DIR}/ObjectSizeCache.cc)
diff --git a/src/api/CMakeLists.txt b/src/api/CMakeLists.txt
index 3fe2b60cbc..642f868d48 100644
--- a/src/api/CMakeLists.txt
+++ b/src/api/CMakeLists.txt
@@ -26,8 +26,8 @@ set(TSAPI_PUBLIC_HEADERS
${PROJECT_SOURCE_DIR}/include/ts/ts.h ${PROJECT_SOURCE_
${PROJECT_SOURCE_DIR}/include/ts/TsException.h
${PROJECT_BINARY_DIR}/include/ts/apidefs.h
)
-# OpenSSL needs to be listed in before PCRE and other libraries that can be
found in the system default lib directory (See # #11511)
-target_link_libraries(tsapi PRIVATE libswoc::libswoc yaml-cpp::yaml-cpp
OpenSSL::SSL PCRE::PCRE PkgConfig::PCRE2)
+# OpenSSL needs to be listed in before other libraries that can be found in
the system default lib directory (See #11511)
+target_link_libraries(tsapi PRIVATE libswoc::libswoc yaml-cpp::yaml-cpp
OpenSSL::SSL)
set_target_properties(tsapi PROPERTIES PUBLIC_HEADER "${TSAPI_PUBLIC_HEADERS}")
# Items common between api and other ts libraries
diff --git a/src/cripts/Matcher.cc b/src/cripts/Matcher.cc
index ea9a8caa5e..fdb380b365 100644
--- a/src/cripts/Matcher.cc
+++ b/src/cripts/Matcher.cc
@@ -55,11 +55,11 @@ Matcher::PCRE::Add(cripts::string_view regex, uint32_t
options, bool jit)
PCRE2_UCHAR error[256];
pcre2_get_error_message(errorcode, error, sizeof(error));
- CFatal("[Matcher::PCRE]: PCRE compile error `%s': %.*s", error,
static_cast<int>(regex.length()), regex.data());
+ CFatal("[Matcher::PCRE]: PCRE2 compile error `%s': %.*s", error,
static_cast<int>(regex.length()), regex.data());
} else {
if (jit) {
if (0 != pcre2_jit_compile(re, PCRE2_JIT_COMPLETE)) {
- CFatal("[Matcher::PCRE]: PCRE JIT compile error: %.*s",
static_cast<int>(regex.length()), regex.data());
+ CFatal("[Matcher::PCRE]: PCRE2 JIT compile error: %.*s",
static_cast<int>(regex.length()), regex.data());
}
}
_regexes.emplace_back(regex, re);
diff --git a/src/proxy/ControlMatcher.cc b/src/proxy/ControlMatcher.cc
index de982f8c8d..8e6b6b7ee5 100644
--- a/src/proxy/ControlMatcher.cc
+++ b/src/proxy/ControlMatcher.cc
@@ -481,10 +481,10 @@ RegexMatcher<Data, MatchResult>::Match(RequestData
*rdata, MatchResult *result)
if (r >= 0) {
Dbg(dbg_ctl_matcher, "%s Matched %s with regex at line %d",
matcher_name, url_str, data_array[i].line_num);
data_array[i].UpdateMatch(result, rdata);
- } else if (r != PCRE2_ERROR_NOMATCH) {
+ } else if (r != RE_ERROR_NOMATCH) {
// An error has occurred
Warning("Error matching regex for url: %s:%d (%d)", file_name ?
file_name : "unknown", data_array[i].line_num, r);
- } // else: PCRE2_ERROR_NOMATCH
+ } // else: RE_ERROR_NOMATCH
}
ats_free(url_str);
}
@@ -529,11 +529,11 @@ HostRegexMatcher<Data, MatchResult>::Match(RequestData
*rdata, MatchResult *resu
Dbg(dbg_ctl_matcher, "%s Matched %s with regex at line %d",
const_cast<char *>(this->matcher_name), url_str,
this->data_array[i].line_num);
this->data_array[i].UpdateMatch(result, rdata);
- } else if (r != PCRE2_ERROR_NOMATCH) {
+ } else if (r != RE_ERROR_NOMATCH) {
// An error has occurred
Warning("Error matching regex for host: %s:%d (%d)", this->file_name ?
this->file_name : "unknown",
this->data_array[i].line_num, r);
- } // else: PCRE2_ERROR_NOMATCH
+ } // else: RE_ERROR_NOMATCH
}
}
diff --git a/src/proxy/hdrs/HdrToken.cc b/src/proxy/hdrs/HdrToken.cc
index c57089ced5..40a2c6033f 100644
--- a/src/proxy/hdrs/HdrToken.cc
+++ b/src/proxy/hdrs/HdrToken.cc
@@ -43,7 +43,7 @@ DbgCtl dbg_ctl_hdr_token{"hdr_token"};
You want a regexp like 'Accept' after "greedier" choices so it doesn't match
'Accept-Ranges' earlier than
it should. The regexp are anchored (^Accept), but I dont see a way with the
current system to
- match the word ONLY without making _hdrtoken_strs a real PCRE, but then that
breaks the hashing
+ match the word ONLY without making _hdrtoken_strs a real PCRE2, but then that
breaks the hashing
hdrtoken_hash("^Accept$") != hdrtoken_hash("Accept")
So, the current hack is to have "Accept" follow "Accept-.*", lame, I know
diff --git a/src/tscore/CMakeLists.txt b/src/tscore/CMakeLists.txt
index 64241e0cf0..511f6d018a 100644
--- a/src/tscore/CMakeLists.txt
+++ b/src/tscore/CMakeLists.txt
@@ -107,14 +107,7 @@ else()
endif()
target_link_libraries(
- tscore
- PUBLIC OpenSSL::Crypto
- PCRE::PCRE
- libswoc::libswoc
- yaml-cpp::yaml-cpp
- systemtap::systemtap
- resolv::resolv
- ts::tsutil
+ tscore PUBLIC OpenSSL::Crypto libswoc::libswoc yaml-cpp::yaml-cpp
systemtap::systemtap resolv::resolv ts::tsutil
)
if(TS_USE_POSIX_CAP)
diff --git a/tools/hrw4u/src/lsp/documentation.py
b/tools/hrw4u/src/lsp/documentation.py
index 4ed3f1c162..f09e28de12 100644
--- a/tools/hrw4u/src/lsp/documentation.py
+++ b/tools/hrw4u/src/lsp/documentation.py
@@ -663,7 +663,7 @@ LSP_COOKIE_DOCUMENTATION: Final[dict[str,
DocumentationInfo]] = {
class RegexPattern:
"""Parser and documentation provider for regular expression patterns."""
- # PCRE flag documentation
+ # PCRE2 flag documentation
FLAG_DOCUMENTATION: Final[dict[str, str]] = {
'i': 'Case-insensitive matching - ignore letter case differences',
'g': 'Global matching - find all matches, not just the first',
@@ -672,8 +672,8 @@ class RegexPattern:
'x': 'Extended mode - ignore whitespace and allow comments',
}
- # Common PCRE syntax reference
- PCRE_SYNTAX_REFERENCE: Final[list[tuple[str, str]]] = [
+ # Common PCRE2 syntax reference
+ PCRE2_SYNTAX_REFERENCE: Final[list[tuple[str, str]]] = [
('\\d', 'digit (0-9)'),
('\\w', 'word character (a-zA-Z0-9_)'),
('\\s', 'whitespace character'),
@@ -739,7 +739,7 @@ class RegexPattern:
# Brief version for LSP hover - most important info first
doc_parts = [
f"**Regular Expression Pattern**", "", f"**Pattern:**
`{full_regex}`", "",
- "**Context:** PCRE-compatible regex for string matching"
+ "**Context:** PCRE2-compatible regex for string matching"
]
if flags:
@@ -749,7 +749,7 @@ class RegexPattern:
doc_parts.append(f"- `{flag}`:
{RegexPattern.FLAG_DOCUMENTATION[flag]}")
syntax_help = []
- for syntax, description in RegexPattern.PCRE_SYNTAX_REFERENCE[:6]:
# First 6 most common
+ for syntax, description in
RegexPattern.PCRE2_SYNTAX_REFERENCE[:6]: # First 6 most common
if syntax.replace('\\', '\\') in pattern:
syntax_help.append(f"- `{syntax}` - {description}")
@@ -760,8 +760,8 @@ class RegexPattern:
# Full documentation version
doc_parts = [
f"**Regular Expression Pattern**", "", f"**Pattern:**
`{full_regex}`", "",
- "**Context:** PCRE-compatible regular expression for string
matching", "",
- "**Description:** This pattern uses Perl Compatible Regular
Expression (PCRE) syntax for matching strings. Common in conditions with the
`~` operator for pattern matching."
+ "**Context:** PCRE2-compatible regular expression for string
matching", "",
+ "**Description:** This pattern uses Perl Compatible Regular
Expression (PCRE2) syntax for matching strings. Common in conditions with the
`~` operator for pattern matching."
]
if flags:
@@ -770,9 +770,9 @@ class RegexPattern:
if flag in RegexPattern.FLAG_DOCUMENTATION:
doc_parts.append(f"- `{flag}`:
{RegexPattern.FLAG_DOCUMENTATION[flag]}")
- # Add complete PCRE syntax help
- doc_parts.extend(["", "**Common PCRE Syntax:**"])
- for syntax, description in RegexPattern.PCRE_SYNTAX_REFERENCE:
+ # Add complete PCRE2 syntax help
+ doc_parts.extend(["", "**Common PCRE2 Syntax:**"])
+ for syntax, description in RegexPattern.PCRE2_SYNTAX_REFERENCE:
doc_parts.append(f"- `{syntax}` - {description}")
doc_parts.extend(