Rebuild with utf-8 encoding
[privoxy.git] / filters.c
index 3c3ae38..60d420f 100644 (file)
--- a/filters.c
+++ b/filters.c
@@ -1,4 +1,4 @@
-const char filters_rcs[] = "$Id: filters.c,v 1.167 2012/03/04 11:51:25 fabiankeil Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.175 2012/10/21 12:58:03 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/filters.c,v $
@@ -261,7 +261,7 @@ int block_acl(const struct access_control_addr *dst, const struct client_state *
 #else
             (csp->ip_addr_long & acl->src->mask) == acl->src->addr
 #endif
-           )
+            )
       {
          if (dst == NULL)
          {
@@ -291,7 +291,7 @@ int block_acl(const struct access_control_addr *dst, const struct client_state *
                ((dst->addr & acl->dst->mask) == acl->dst->addr)
            && ((dst->port == acl->dst->port) || (acl->dst->port == 0))
 #endif
-          )
+           )
          {
             if (acl->action == ACL_PERMIT)
             {
@@ -374,7 +374,7 @@ int acl_addr(const char *aspec, struct access_control_addr *aca)
 #else
          (masklength > 32)
 #endif
-        )
+         )
    {
       freez(acl_spec);
       return(-1);
@@ -577,7 +577,7 @@ struct http_response *block_url(struct client_state *csp)
       /* determine HOW images should be blocked */
       p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
 
-      if(csp->action->flags & ACTION_HANDLE_AS_EMPTY_DOCUMENT)
+      if (csp->action->flags & ACTION_HANDLE_AS_EMPTY_DOCUMENT)
       {
          log_error(LOG_LEVEL_ERROR, "handle-as-empty-document overruled by handle-as-image.");
       }
@@ -646,7 +646,7 @@ struct http_response *block_url(struct client_state *csp)
    }
    else
 #endif /* def FEATURE_IMAGE_BLOCKING */
-   if(csp->action->flags & ACTION_HANDLE_AS_EMPTY_DOCUMENT)
+   if (csp->action->flags & ACTION_HANDLE_AS_EMPTY_DOCUMENT)
    {
      /*
       *  Send empty document.
@@ -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,24 +1102,22 @@ 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)
       {
-         log_error(LOG_LEVEL_ERROR, "Out of memory while decoding URL: %s", new_url);
+         log_error(LOG_LEVEL_ERROR,
+            "Out of memory while decoding URL: %s", subject);
          freez(subject);
          return NULL;
       }
 
-      segments = ssplit(subject, "?&", url_segments, max_segments, 1, 1);
+      segments = ssplit(subject, "?&", url_segments, max_segments);
 
       while (segments-- > 0)
       {
@@ -1174,10 +1177,10 @@ char *get_last_url(char *subject, const char *redirect_mode)
    }
 
    if ((new_url != NULL)
-      && ( (new_url != subject)
+      && (  (new_url != subject)
          || (0 == strncmpic(subject, "http://", 7))
          || (0 == strncmpic(subject, "https://", 8))
-        ))
+         ))
    {
       /*
        * Return new URL if we found a redirect
@@ -1472,7 +1475,7 @@ int is_untrusted_url(const struct client_state *csp)
             string_append(&new_entry, csp->http->hostport);
 
             path = csp->http->path;
-            if ((path[0] == '/')
+            if ( (path[0] == '/')
               && (path[1] == '~')
               && ((path_end = strchr(path + 2, '/')) != NULL))
             {
@@ -1689,7 +1692,7 @@ static char *pcrs_filter_response(struct client_state *csp)
 
    csp->flags |= CSP_FLAG_MODIFIED;
    csp->content_length = size;
-   IOB_RESET(csp);
+   clear_iob(csp->iob);
 
    return(new);
 
@@ -1719,8 +1722,8 @@ static char *gif_deanimate_response(struct client_state *csp)
 
    size = (size_t)(csp->iob->eod - csp->iob->cur);
 
-   if ( (NULL == (in =  (struct binbuffer *)zalloc(sizeof *in)))
-      || (NULL == (out = (struct binbuffer *)zalloc(sizeof *out))))
+   if (  (NULL == (in =  (struct binbuffer *)zalloc(sizeof *in )))
+      || (NULL == (out = (struct binbuffer *)zalloc(sizeof *out))) )
    {
       log_error(LOG_LEVEL_DEANIMATE, "failed! (no mem)");
       return NULL;
@@ -2127,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;
@@ -2155,6 +2158,11 @@ const static struct forward_spec *get_forward_override_settings(struct client_st
          fwd->type = SOCKS_5;
          socks_proxy = vec[1];
       }
+      else if (!strcasecmp(vec[0], "forward-socks5t"))
+      {
+         fwd->type = SOCKS_5T;
+         socks_proxy = vec[1];
+      }
 
       if (NULL != socks_proxy)
       {