From 1a04091dfb254e1b89a107d27cccb4c55c565f51 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 12 Dec 2020 11:45:32 +0100 Subject: [PATCH] Log an error when a PCRE-HOST-PATTERN is used with FEATURE_PCRE_HOST_PATTERNS disabled Don't treat this a fatal error so the regression tests can be used with and without FEATURE_PCRE_HOST_PATTERNS. --- urlmatch.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/urlmatch.c b/urlmatch.c index 23a6b543..3cd1147c 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -704,9 +704,9 @@ static jb_err compile_pattern(const char *pattern, enum regex_anchoring anchorin static jb_err compile_url_pattern(struct pattern_spec *url, char *buf) { char *p; + const size_t prefix_length = 18; #ifdef FEATURE_PCRE_HOST_PATTERNS - const size_t prefix_length = 18; if (strncmpic(buf, "PCRE-HOST-PATTERN:", prefix_length) == 0) { url->pattern.url_spec.host_regex_type = PCRE_HOST_PATTERN; @@ -717,6 +717,22 @@ static jb_err compile_url_pattern(struct pattern_spec *url, char *buf) { url->pattern.url_spec.host_regex_type = VANILLA_HOST_PATTERN; } +#else + if (strncmpic(buf, "PCRE-HOST-PATTERN:", prefix_length) == 0) + { + log_error(LOG_LEVEL_ERROR, + "PCRE-HOST-PATTERN detected while Privoxy has been compiled " + "without FEATURE_PCRE_HOST_PATTERNS: %s", + buf); + /* Overwrite the "PCRE-HOST-PATTERN:" prefix */ + memmove(buf, buf+prefix_length, strlen(buf+prefix_length)+1); + /* + * The pattern will probably not work as expected. + * We don't simply return JB_ERR_PARSE here so the + * regression tests can be loaded with and without + * FEATURE_PCRE_HOST_PATTERNS. + */ + } #endif p = strchr(buf, '/'); -- 2.39.2