- re_process_buffer no longer writes the modified buffer
[privoxy.git] / parsers.c
index 18c0a9c..cd03beb 100644 (file)
--- a/parsers.c
+++ b/parsers.c
@@ -1,4 +1,4 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 1.6 2001/05/26 13:39:32 jongfoster Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.7 2001/05/27 13:19:06 oes Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
@@ -41,6 +41,9 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.6 2001/05/26 13:39:32 jongfoster
  *
  * Revisions   :
  *    $Log: parsers.c,v $
+ *    Revision 1.7  2001/05/27 13:19:06  oes
+ *    Patched Joergs solution for the content-length in.
+ *
  *    Revision 1.6  2001/05/26 13:39:32  jongfoster
  *    Only crunches Content-Length header if applying RE filtering.
  *    Without this fix, Microsoft Windows Update wouldn't work.
@@ -522,14 +525,12 @@ char *sed(const struct parsers pats[], void (* const more_headers[])(struct clie
    {
       for (p = csp->headers->next; p ; p = p->next)
       {
+         /* Header crunch()ed in previous run? -> ignore */
+         if (p->str == NULL) continue;
+
          if (v == pats) log_error(LOG_LEVEL_HEADER, "scan: %s", p->str);
 
-         if (p->str == NULL)
-         {
-            /* hit me */
-            log_error(LOG_LEVEL_ERROR, "NULL header");
-         }
-         else if (strncmpic(p->str, v->str, v->len) == 0)
+         if (strncmpic(p->str, v->str, v->len) == 0)
          {
             hdr = v->parser(v, p->str, csp);
             freez(p->str);
@@ -544,8 +545,11 @@ char *sed(const struct parsers pats[], void (* const more_headers[])(struct clie
       (*f)(csp);
    }
 
-   /* add the blank line at the end of the header */
-   enlist(csp->headers, "");
+   /* add the blank line at the end of the header, if necessary */
+   if(strlen(csp->headers->last->str) != 0)
+   {
+      enlist(csp->headers, "");
+   }
 
    hdr = list_to_text(csp->headers);
 
@@ -798,11 +802,13 @@ char *content_type(const struct parsers *v, char *s, struct client_state *csp)
  *********************************************************************/
 char *content_length(const struct parsers *v, char *s, struct client_state *csp)
 {
-   if (((csp->permissions & PERMIT_RE_FILTER) != 0) && csp->is_text)
-   {
-      log_error(LOG_LEVEL_HEADER, "crunch!");
-      return(NULL);
-   }
+   if (csp->content_length != 0) /* Content has been modified */
+       {
+          s = (char *) zalloc(100);
+          snprintf(s, 100, "Content-Length: %d", csp->content_length);
+               log_error(LOG_LEVEL_HEADER, "Adjust Content-Length to %d", csp->content_length);
+          return(s);
+       }
    else
    {
       return(strdup(s));