From 320eccab4446fb0083c623c22c9fd86ac7e3da21 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Mon, 1 Sep 2025 15:21:12 +0300 Subject: [PATCH] lib-regex: Fail if PCRE2_SUBSTITUTE_LITERAL is not supported by pcre2 --- src/lib-regex/regex.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib-regex/regex.c b/src/lib-regex/regex.c index 66c5f6238e..e402e6a49d 100644 --- a/src/lib-regex/regex.c +++ b/src/lib-regex/regex.c @@ -369,8 +369,14 @@ int dregex_code_replace_full(struct dregex_code *code, options |= PCRE2_ANCHORED; if (HAS_ALL_BITS(flags, DREGEX_REPLACE_ALL)) options |= PCRE2_SUBSTITUTE_GLOBAL; - if (HAS_ALL_BITS(flags, DREGEX_REPLACE_LITERAL)) + if (HAS_ALL_BITS(flags, DREGEX_REPLACE_LITERAL)) { +#ifdef PCRE2_SUBSTITUTE_LITERAL options |= PCRE2_SUBSTITUTE_LITERAL; +#else + *error_r = "DREGEX_REPLACE_LITERAL not supported on this platform"; + return -1; +#endif + } PCRE2_UCHAR *result32 = U""; PCRE2_SIZE result_len = 0; -- 2.47.3