X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=filters.c;h=65308f5c40839d2ee791da5f37d4154eb8101d2a;hb=8bd12093587d9c3d65cccd7106ca2f4085df3c99;hp=0b643a395058cd99de12bbc7c3671a4d0c58789a;hpb=b77f124709dbf693508cd10e34b2e21b52f7a114;p=privoxy.git diff --git a/filters.c b/filters.c index 0b643a39..65308f5c 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.170 2012/03/09 17:55:50 fabiankeil Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.172 2012/06/08 15:15:11 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -1088,6 +1088,11 @@ char *get_last_url(char *subject, const char *redirect_mode) if (0 == strcmpic(redirect_mode, "check-decoded-url") && strchr(subject, '%')) { + char *url_segment = NULL; + char **url_segments; + size_t max_segments; + int segments; + log_error(LOG_LEVEL_REDIRECTS, "Checking \"%s\" for encoded redirects.", subject); @@ -1097,15 +1102,12 @@ char *get_last_url(char *subject, const char *redirect_mode) * go backwards through the segments, URL-decode them * and look for a URL in the decoded result. * Stop the search after the first match. - */ - char *url_segment = NULL; - /* + * * XXX: This estimate is guaranteed to be high enough as we * let ssplit() ignore empty fields, but also a bit wasteful. */ - size_t max_segments = strlen(subject) / 2; - char **url_segments = malloc(max_segments * sizeof(char *)); - int segments; + max_segments = strlen(subject) / 2; + url_segments = malloc(max_segments * sizeof(char *)); if (NULL == url_segments) { @@ -1115,7 +1117,7 @@ char *get_last_url(char *subject, const char *redirect_mode) return NULL; } - segments = ssplit(subject, "?&", url_segments, max_segments, 1, 1); + segments = ssplit(subject, "?&", url_segments, max_segments); while (segments-- > 0) { @@ -2128,7 +2130,7 @@ const static struct forward_spec *get_forward_override_settings(struct client_st return NULL; } - vec_count = ssplit(forward_settings, " \t", vec, SZ(vec), 1, 1); + vec_count = ssplit(forward_settings, " \t", vec, SZ(vec)); if ((vec_count == 2) && !strcasecmp(vec[0], "forward")) { fwd->type = SOCKS_NONE;