- Let msn hide sponsored links in #ar divs.
[privoxy.git] / parsers.c
index 2bd062b..61f514d 100644 (file)
--- a/parsers.c
+++ b/parsers.c
@@ -1,4 +1,4 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 1.108 2007/08/28 18:21:03 fabiankeil Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.110 2007/09/29 10:42:37 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
@@ -44,6 +44,13 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.108 2007/08/28 18:21:03 fabiankei
  *
  * Revisions   :
  *    $Log: parsers.c,v $
+ *    Revision 1.110  2007/09/29 10:42:37  fabiankeil
+ *    - Remove "scanning headers for" log message again.
+ *    - Some more whitespace fixes.
+ *
+ *    Revision 1.109  2007/09/08 14:25:48  fabiankeil
+ *    Refactor client_referrer() and add conditional-forge parameter.
+ *
  *    Revision 1.108  2007/08/28 18:21:03  fabiankeil
  *    A bunch of whitespace fixes, pointy hat to me.
  *
@@ -865,12 +872,21 @@ const add_header_func_ptr add_client_headers[] = {
    NULL
 };
 
-
 const add_header_func_ptr add_server_headers[] = {
    connection_close_adder,
    NULL
 };
 
+/* The vanilla wafer. */
+static const char VANILLA_WAFER[] =
+   "NOTICE=TO_WHOM_IT_MAY_CONCERN_"
+   "Do_not_send_me_any_copyrighted_information_other_than_the_"
+   "document_that_I_am_requesting_or_any_of_its_necessary_components._"
+   "In_particular_do_not_send_me_any_cookies_that_"
+   "are_subject_to_a_claim_of_copyright_by_anybody._"
+   "Take_notice_that_I_refuse_to_be_bound_by_any_license_condition_"
+   "(copyright_or_otherwise)_applying_to_any_cookie._";
+
 /*********************************************************************
  *
  * Function    :  flush_socket
@@ -1104,7 +1120,7 @@ jb_err decompress_iob(struct client_state *csp)
              * The number of bytes to skip should be positive
              * and we'd like to stay in the buffer.
              */
-            if((skip_bytes < 0) || (skip_bytes >= (csp->iob->eod - cur)))
+            if ((skip_bytes < 0) || (skip_bytes >= (csp->iob->eod - cur)))
             {
                log_error(LOG_LEVEL_ERROR,
                   "Unreasonable amount of bytes to skip (%d). Stopping decompression",
@@ -1481,8 +1497,6 @@ static jb_err scan_headers(struct client_state *csp)
    struct list_entry *h; /* Header */
    jb_err err = JB_ERR_OK;
 
-   log_error(LOG_LEVEL_HEADER, "scanning headers for: %s", csp->http->url);
-
    for (h = csp->headers->first; (err == JB_ERR_OK) && (h != NULL) ; h = h->next)
    {
       /* Header crunch()ed in previous run? -> ignore */
@@ -1507,6 +1521,8 @@ static jb_err scan_headers(struct client_state *csp)
  *                As a side effect it frees the space used by the original
  *                header lines.
  *
+ *                XXX: should be split to remove the first_run hack.
+ *
  * Parameters  :
  *          1  :  pats = list of patterns to match against headers
  *          2  :  more_headers = list of functions to add more
@@ -1936,7 +1952,7 @@ static jb_err filter_header(struct client_state *csp, char **header)
                      /* RegEx failure */
                      log_error(LOG_LEVEL_ERROR, "Filtering \'%s\' with \'%s\' didn't work out: %s",
                         *header, b->name, pcrs_strerror(matches));
-                     ifnewheader != NULL)
+                     if (newheader != NULL)
                      {
                         log_error(LOG_LEVEL_ERROR, "Freeing what's left: %s", newheader);
                         freez(newheader);
@@ -2042,6 +2058,7 @@ static jb_err crumble(struct client_state *csp, char **header)
    return JB_ERR_OK;
 }
 
+
 /*********************************************************************
  *
  * Function    :  crunch_server_header
@@ -2398,6 +2415,7 @@ static jb_err server_content_md5(struct client_state *csp, char **header)
    return JB_ERR_OK;
 }
 
+
 /*********************************************************************
  *
  * Function    :  server_content_disposition
@@ -2461,6 +2479,7 @@ static jb_err server_content_disposition(struct client_state *csp, char **header
    return (*header == NULL) ? JB_ERR_MEMORY : JB_ERR_OK;
 }
 
+
 /*********************************************************************
  *
  * Function    :  server_last_modified
@@ -2580,7 +2599,7 @@ static jb_err server_last_modified(struct client_state *csp, char **header)
                return JB_ERR_MEMORY;  
             }
 
-            if(LOG_LEVEL_HEADER & debug) /* Save cycles if the user isn't interested. */
+            if (LOG_LEVEL_HEADER & debug) /* Save cycles if the user isn't interested. */
             {
                days    = rtime / (3600 * 24);
                hours   = rtime / 3600 % 24;
@@ -2904,6 +2923,7 @@ static jb_err client_uagent(struct client_state *csp, char **header)
    return (*header == NULL) ? JB_ERR_MEMORY : JB_ERR_OK;
 }
 
+
 /*********************************************************************
  *
  * Function    :  client_ua
@@ -3197,6 +3217,7 @@ static jb_err client_host(struct client_state *csp, char **header)
    return JB_ERR_OK;
 }
 
+
 /*********************************************************************
  *
  * Function    :  client_if_modified_since
@@ -3261,11 +3282,11 @@ static jb_err client_if_modified_since(struct client_state *csp, char **header)
          else
          {
             rtime = strtol(newval, &endptr, 0);
-            if(rtime)
+            if (rtime)
             {
                log_error(LOG_LEVEL_HEADER, "Randomizing: %s (random range: %d minut%s)",
                   *header, rtime, (rtime == 1 || rtime == -1) ? "e": "es");
-               if(rtime < 0)
+               if (rtime < 0)
                {
                   rtime *= -1; 
                   negative = 1;
@@ -3300,7 +3321,7 @@ static jb_err client_if_modified_since(struct client_state *csp, char **header)
                return JB_ERR_MEMORY;  
             }
 
-            if(LOG_LEVEL_HEADER & debug) /* Save cycles if the user isn't interested. */
+            if (LOG_LEVEL_HEADER & debug) /* Save cycles if the user isn't interested. */
             {
                hours   = rtime / 3600;
                minutes = rtime / 60 % 60;
@@ -3317,6 +3338,7 @@ static jb_err client_if_modified_since(struct client_state *csp, char **header)
    return JB_ERR_OK;
 }
 
+
 /*********************************************************************
  *
  * Function    :  client_if_none_match
@@ -3345,6 +3367,7 @@ static jb_err client_if_none_match(struct client_state *csp, char **header)
    return JB_ERR_OK;
 }
 
+
 /*********************************************************************
  *
  * Function    :  client_x_filter
@@ -3462,9 +3485,21 @@ jb_err client_cookie_adder(struct client_state *csp)
 {
    char *tmp;
    struct list_entry *wafer;
-   struct list_entry *wafer_list = csp->action->multi[ACTION_MULTI_WAFER]->first;
+   struct list_entry *wafer_list;
    jb_err err;
 
+   /*
+    * If the user has not supplied any wafers, and the user has not
+    * told us to suppress the vanilla wafer, then send the vanilla wafer.
+    */
+   if ((0 != (csp->action->flags & ACTION_VANILLA_WAFER))
+      && list_is_empty(csp->action->multi[ACTION_MULTI_WAFER]))
+   {
+      enlist(csp->action->multi[ACTION_MULTI_WAFER], VANILLA_WAFER);
+   }
+
+   wafer_list = csp->action->multi[ACTION_MULTI_WAFER]->first;
+
    if (NULL == wafer_list)
    {
       /* Nothing to do */
@@ -3950,6 +3985,7 @@ int strclean(const char *string, const char *substring)
 }
 #endif /* def FEATURE_FORCE_LOAD */
 
+
 /*********************************************************************
  *
  * Function    :  parse_header_time
@@ -3999,6 +4035,7 @@ static jb_err parse_header_time(const char *header_time, time_t *result)
 
 }
 
+
 /*********************************************************************
  *
  * Function    :  get_destination_from_headers