[Privoxy-commits] [privoxy] 04/08: compile_pattern(): Use pcre2_get_error_message() to provide better error messages
User Git
git at git.privoxy.org
Sat Apr 5 14:18:52 CEST 2025
This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository privoxy.
commit 7048c69604ebf29fe79116c1d7c322bebc391150
Author: Fabian Keil <fk at fabiankeil.de>
AuthorDate: Sat Jan 25 19:11:26 2025 +0100
compile_pattern(): Use pcre2_get_error_message() to provide better error messages
---
urlmatch.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/urlmatch.c b/urlmatch.c
index 494a69a9..ea433d9a 100644
--- a/urlmatch.c
+++ b/urlmatch.c
@@ -628,6 +628,7 @@ jb_err parse_http_request(const char *req, struct http_request *http)
static jb_err compile_pattern(const char *pattern, enum regex_anchoring anchoring,
struct pattern_spec *url, pcre2_code **regex)
{
+ PCRE2_UCHAR error_message[120];
int errcode;
const char *fmt = NULL;
char *rebuf;
@@ -671,8 +672,9 @@ static jb_err compile_pattern(const char *pattern, enum regex_anchoring anchorin
&error_offset, NULL);
if (*regex == NULL)
{
- log_error(LOG_LEVEL_ERROR, "error compiling %s from %s: %s",
- pattern, url->spec, rebuf);
+ pcre2_get_error_message(errcode, error_message, sizeof(error_message));
+ log_error(LOG_LEVEL_ERROR, "Failed to compile '%s' (%s) from '%s': %s",
+ pattern, rebuf, url->spec, error_message);
freez(rebuf);
return JB_ERR_PARSE;
@@ -683,9 +685,10 @@ static jb_err compile_pattern(const char *pattern, enum regex_anchoring anchorin
if ((ret = pcre2_jit_compile(*regex, PCRE2_JIT_COMPLETE)) &&
(ret != PCRE2_ERROR_JIT_BADOPTION))
{
+ pcre2_get_error_message(ret, error_message, sizeof(error_message));
log_error(LOG_LEVEL_ERROR,
- "Unexpected error enabling JIT compilation for %s from %s: %s",
- pattern, url->spec, rebuf);
+ "Failed to JIT-compile '%s' (%s) from '%s': %s",
+ pattern, rebuf, url->spec, error_message);
freez(rebuf);
return JB_ERR_PARSE;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Privoxy-commits
mailing list