X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=urlmatch.c;h=4670f310aea5c4e2fd3b7d1addf879ed56c0f766;hp=868a16b3806d94cb65adb251727d90cceac58c6a;hb=a5b4d31ab5ad2ed24cdb53ffa92679411b4176b0;hpb=72c9421cb5d9b4155140db25d1bfc41e7ef90040 diff --git a/urlmatch.c b/urlmatch.c index 868a16b3..4670f310 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -45,7 +45,7 @@ #include #include -#if !defined(_WIN32) && !defined(__OS2__) +#if !defined(_WIN32) #include #endif @@ -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; @@ -302,7 +304,7 @@ jb_err parse_http_url(const char *url, struct http_request *http, int require_pr url_path ); *url_path = '\0'; - http->hostport = strdup_or_die(url_noproto); + http->hostport = string_tolower(url_noproto); } else { @@ -311,10 +313,15 @@ jb_err parse_http_url(const char *url, struct http_request *http, int require_pr * or CONNECT requests */ http->path = strdup_or_die("/"); - http->hostport = strdup_or_die(url_noproto); + http->hostport = string_tolower(url_noproto); } freez(buf); + + if (http->hostport == NULL) + { + return JB_ERR_PARSE; + } } if (!host_available) @@ -699,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; @@ -712,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, '/'); @@ -1301,7 +1324,8 @@ static int host_matches(const struct http_request *http, { assert(http->host != NULL); #ifdef FEATURE_PCRE_HOST_PATTERNS - if (pattern->pattern.url_spec.host_regex_type == PCRE_HOST_PATTERN) { + if (pattern->pattern.url_spec.host_regex_type == PCRE_HOST_PATTERN) + { return ((NULL == pattern->pattern.url_spec.host_regex) || (0 == regexec(pattern->pattern.url_spec.host_regex, http->host, 0, NULL, 0)));