Re-generated from sgml source
[privoxy.git] / parsers.c
index b7d2de3..9527cbd 100644 (file)
--- a/parsers.c
+++ b/parsers.c
@@ -1,4 +1,4 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 1.56.2.5 2003/04/14 12:08:16 oes Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.56.2.7 2003/05/06 12:07:26 oes Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/Attic/parsers.c,v $
@@ -40,6 +40,12 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.56.2.5 2003/04/14 12:08:16 oes Ex
  *
  * Revisions   :
  *    $Log: parsers.c,v $
+ *    Revision 1.56.2.7  2003/05/06 12:07:26  oes
+ *    Fixed bug #729900: Suspicious HOST: headers are now killed and regenerated if necessary
+ *
+ *    Revision 1.56.2.6  2003/04/14 21:28:30  oes
+ *    Completing the previous change
+ *
  *    Revision 1.56.2.5  2003/04/14 12:08:16  oes
  *    Added temporary workaround for bug in PHP < 4.2.3
  *
@@ -821,6 +827,9 @@ jb_err crumble(struct client_state *csp, char **header)
  * Description :  Set the content-type for filterable types (text/.*,
  *                javascript and image/gif) unless filtering has been
  *                forbidden (CT_TABOO) while parsing earlier headers.
+ *                NOTE: Since text/plain is commonly used by web servers
+ *                      for files whose correct type is unknown, we don't
+ *                      set CT_TEXT for it.
  *
  * Parameters  :
  *          1  :  csp = Current client state (buffers, headers, etc...)
@@ -837,7 +846,7 @@ jb_err server_content_type(struct client_state *csp, char **header)
 {
    if (csp->content_type != CT_TABOO)
    {
-      if (strstr(*header, " text/")
+      if ((strstr(*header, " text/") && !strstr(*header, "plain"))
        || strstr(*header, "application/x-javascript"))
          csp->content_type = CT_TEXT;
       else if (strstr(*header, " image/gif"))
@@ -1422,6 +1431,9 @@ jb_err client_max_forwards(struct client_state *csp, char **header)
  *                port information, parse and evaluate the Host
  *                header field.
  *
+ *                Also, kill ill-formed HOST: headers as sent by
+ *                Apple's iTunes software when used with a proxy.
+ *
  * Parameters  :
  *          1  :  csp = Current client state (buffers, headers, etc...)
  *          2  :  header = On input, pointer to header to modify.
@@ -1437,6 +1449,18 @@ jb_err client_host(struct client_state *csp, char **header)
 {
    char *p, *q;
 
+   /*
+    * If the header field name is all upper-case, chances are that it's
+    * an ill-formed one from iTunes. BTW, killing innocent headers here is
+    * not a problem -- they are regenerated later.
+    */
+   if ((*header)[1] == 'O')
+   {
+      log_error(LOG_LEVEL_HEADER, "Killed all-caps Host header line: %s", *header);
+      freez(*header);
+      return JB_ERR_OK;
+   }
+
    if (!csp->http->hostport || (*csp->http->hostport == '*') ||  
        *csp->http->hostport == ' ' || *csp->http->hostport == '\0')
    {