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 cbe91698e2 Convert records to use Regex wrappers instead of pcre
directly (#11279)
cbe91698e2 is described below
commit cbe91698e2054ddb0ac33d34a92e270fa9194909
Author: Bryan Call <[email protected]>
AuthorDate: Tue Apr 23 09:07:35 2024 -0700
Convert records to use Regex wrappers instead of pcre directly (#11279)
---
src/records/RecUtils.cc | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/src/records/RecUtils.cc b/src/records/RecUtils.cc
index 8aaeecd4ba..51e76977cb 100644
--- a/src/records/RecUtils.cc
+++ b/src/records/RecUtils.cc
@@ -21,18 +21,11 @@
limitations under the License.
*/
-#if __has_include("pcre/pcre.h")
-#include <pcre/pcre.h>
-#elif __has_include("pcre.h")
-#include <pcre.h>
-#else
-#error "Unable to locate PCRE heeader"
-#endif
-
#include "tscore/ink_platform.h"
#include "tscore/ink_memory.h"
#include "tscore/ParseRules.h"
#include "tscore/Tokenizer.h"
+#include "tsutil/Regex.h"
#include "records/RecordsConfig.h"
#include "P_RecUtils.h"
#include "P_RecCore.h"
@@ -390,18 +383,13 @@ namespace
bool
recordRegexCheck(const char *pattern, const char *value)
{
- pcre *regex;
- const char *error;
- int erroffset;
+ Regex regex;
- regex = pcre_compile(pattern, 0, &error, &erroffset, nullptr);
- if (!regex) {
+ bool rval = regex.compile(pattern);
+ if (rval == false) {
return false;
} else {
- int r = pcre_exec(regex, nullptr, value, strlen(value), 0, 0, nullptr, 0);
-
- pcre_free(regex);
- return (r != -1) ? true : false;
+ return regex.exec(value);
}
return false; // no-op