X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=urlmatch.c;h=750cd242a1da3ae45d329d49d7ea7bd7e3490aad;hp=23a6b54363ef76250638ba13a27f40625146eb0a;hb=6f826450179f69f481c58d365e274ab5b1896709;hpb=c83713758e9465e03ec3b0228c433e6f2d843352 diff --git a/urlmatch.c b/urlmatch.c index 23a6b543..750cd242 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -263,7 +263,9 @@ jb_err parse_http_url(const char *url, struct http_request *http, int require_pr else if (strncmpic(url_noproto, "https://", 8) == 0) { /* - * Should only happen when called from cgi_show_url_info(). + * Should only happen when called from cgi_show_url_info() + * or when the request was https-inspected and the request + * line got rewritten. */ url_noproto += 8; http->ssl = 1; @@ -704,9 +706,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 +719,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, '/'); @@ -1188,9 +1206,9 @@ jb_err create_pattern_spec(struct pattern_spec *pattern, char *buf) const unsigned flag; } tag_pattern[] = { { "TAG:", 4, PATTERN_SPEC_TAG_PATTERN}, - #ifdef FEATURE_CLIENT_TAGS +#ifdef FEATURE_CLIENT_TAGS { "CLIENT-TAG:", 11, PATTERN_SPEC_CLIENT_TAG_PATTERN}, - #endif +#endif { "NO-REQUEST-TAG:", 15, PATTERN_SPEC_NO_REQUEST_TAG_PATTERN}, { "NO-RESPONSE-TAG:", 16, PATTERN_SPEC_NO_RESPONSE_TAG_PATTERN} }; @@ -1245,6 +1263,17 @@ void free_pattern_spec(struct pattern_spec *pattern) if (pattern == NULL) return; freez(pattern->spec); + + if (!(pattern->flags & PATTERN_SPEC_URL_PATTERN)) + { + if (pattern->pattern.tag_regex) + { + regfree(pattern->pattern.tag_regex); + freez(pattern->pattern.tag_regex); + } + return; + } + #ifdef FEATURE_PCRE_HOST_PATTERNS if (pattern->pattern.url_spec.host_regex) { @@ -1261,11 +1290,6 @@ void free_pattern_spec(struct pattern_spec *pattern) regfree(pattern->pattern.url_spec.preg); freez(pattern->pattern.url_spec.preg); } - if (pattern->pattern.tag_regex) - { - regfree(pattern->pattern.tag_regex); - freez(pattern->pattern.tag_regex); - } }