Workaround for firefox hanging on blocked javascript pages
authorLee <ler762@users.sourceforge.net>
Sun, 10 Jan 2010 13:53:49 +0000 (13:53 +0000)
committerLee <ler762@users.sourceforge.net>
Sun, 10 Jan 2010 13:53:49 +0000 (13:53 +0000)
doc/source/p-config.sgml
filters.c
loadcfg.c
project.h

index 8594df0..44570e6 100644 (file)
@@ -3,7 +3,7 @@
 
  Purpose     :  Used with other docs and files only.
 
 
  Purpose     :  Used with other docs and files only.
 
- $Id: p-config.sgml,v 2.54 2009/11/27 13:47:34 fabiankeil Exp $
+ $Id: p-config.sgml,v 2.55 2009/12/15 17:43:40 fabiankeil Exp $
 
  Copyright (C) 2001-2009 Privoxy Developers http://www.privoxy.org/
  See LICENSE.
 
  Copyright (C) 2001-2009 Privoxy Developers http://www.privoxy.org/
  See LICENSE.
@@ -97,7 +97,7 @@
  Sample Configuration File for Privoxy v&p-version;
 </title>
 <para>
  Sample Configuration File for Privoxy v&p-version;
 </title>
 <para>
- $Id: p-config.sgml,v 2.54 2009/11/27 13:47:34 fabiankeil Exp $
+ $Id: p-config.sgml,v 2.55 2009/12/15 17:43:40 fabiankeil Exp $
 </para>
 <para>
 Copyright (C) 2001-2009 Privoxy Developers http://www.privoxy.org/
 </para>
 <para>
 Copyright (C) 2001-2009 Privoxy Developers http://www.privoxy.org/
@@ -2868,6 +2868,64 @@ forward-socks4, forward-socks4a and forward-socks5</title>
 </sect3>
 
 
 </sect3>
 
 
+<sect3 renderas="sect4" id="handle-as-empty-doc-returns-ok"><title>handle-as-empty-doc-returns-ok</title>
+<variablelist>
+ <varlistentry>
+  <term>Note:</term>
+  <listitem>
+   <para>
+    This is a work-around for Firefox bug 492459:
+    <quote>
+    Websites are no longer rendered if SSL requests for JavaScripts are blocked by a proxy.
+    </quote>
+    (<link linkend="https://bugzilla.mozilla.org/show_bug.cgi?id=492459">
+                    https://bugzilla.mozilla.org/show_bug.cgi?id=492459</link>)
+   </para>
+  </listitem>
+ </varlistentry>
+ <varlistentry>
+  <term>Specifies:</term>
+  <listitem>
+   <para>
+    The status code Privoxy returns for pages blocked with
+    <literal><link linkend="handle-as-empty-document">+handle-as-empty-document</link></literal>.
+   </para>
+  </listitem>
+ </varlistentry>
+ <varlistentry>
+  <term>Type of value:</term>
+  <listitem>
+   <para>
+    <replaceable>0 or 1</replaceable>
+   </para>
+  </listitem>
+ </varlistentry>
+ <varlistentry>
+  <term>Default value:</term>
+  <listitem>
+   <para>0</para>
+  </listitem>
+ </varlistentry>
+ <varlistentry>
+  <term>Effect if unset:</term>
+  <listitem>
+   <para>
+    Privoxy returns a status 403(forbidden) for all blocked pages.
+   </para>
+  </listitem>
+  <term>Effect if set:</term>
+  <listitem>
+   <para>
+    Privoxy returns a status 200(OK) for pages blocked with +handle-as-empty-document
+    and a status 403(Forbidden) for all other blocked pages.
+   </para>
+  </listitem>
+ </varlistentry>
+</variablelist>
+<![%config-file;[<literallayout>@@#handle-as-empty-doc-returns-ok 0</literallayout>]]>
+</sect3>
+
+
 </sect2>
 
 <!--  ~  End section  ~  -->
 </sect2>
 
 <!--  ~  End section  ~  -->
index 219c581..d122d84 100644 (file)
--- a/filters.c
+++ b/filters.c
@@ -1,4 +1,4 @@
-const char filters_rcs[] = "$Id: filters.c,v 1.124 2009/08/19 15:24:30 fabiankeil Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.125 2009/10/25 15:23:40 ler762 Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/filters.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/filters.c,v $
@@ -702,7 +702,21 @@ struct http_response *block_url(struct client_state *csp)
       rsp->body = strdup(" ");
       rsp->content_length = 1;
 
       rsp->body = strdup(" ");
       rsp->content_length = 1;
 
-      rsp->status = strdup("403 Request blocked by Privoxy");
+      if (csp->config->feature_flags & RUNTIME_FEATURE_EMPTY_DOC_RETURNS_OK)
+      {
+         /*
+          * Workaround for firefox bug 492459
+          *   https://bugzilla.mozilla.org/show_bug.cgi?id=492459
+          * Return a 200 OK status for pages blocked with +handle-as-empty-document
+          * if the "handle-as-empty-doc-returns-ok" runtime config option is set.
+          */
+         rsp->status = strdup("200 Request blocked by Privoxy");
+      }
+      else
+      {
+         rsp->status = strdup("403 Request blocked by Privoxy");
+      }
+
       if (rsp->status == NULL)
       {
          free_http_response(rsp);
       if (rsp->status == NULL)
       {
          free_http_response(rsp);
index b5512d7..5f88d75 100644 (file)
--- a/loadcfg.c
+++ b/loadcfg.c
@@ -1,4 +1,4 @@
-const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.107 2009/11/27 13:46:47 fabiankeil Exp $";
+const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.108 2010/01/03 12:37:14 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
@@ -148,6 +148,7 @@ static struct file_list *current_configfile = NULL;
 #define hash_forward_socks4a             2639958518ul /* "forward-socks4a" */
 #define hash_forward_socks5              3963965522ul /* "forward-socks5" */
 #define hash_forwarded_connect_retries    101465292ul /* "forwarded-connect-retries" */
 #define hash_forward_socks4a             2639958518ul /* "forward-socks4a" */
 #define hash_forward_socks5              3963965522ul /* "forward-socks5" */
 #define hash_forwarded_connect_retries    101465292ul /* "forwarded-connect-retries" */
+#define hash_handle_as_empty_returns_ok  1444873247ul /* "handle-as-empty-doc-returns-ok" */
 #define hash_hostname                      10308071ul /* "hostname" */
 #define hash_keep_alive_timeout          3878599515ul /* "keep-alive-timeout" */
 #define hash_listen_address              1255650842ul /* "listen-address" */
 #define hash_hostname                      10308071ul /* "hostname" */
 #define hash_keep_alive_timeout          3878599515ul /* "keep-alive-timeout" */
 #define hash_listen_address              1255650842ul /* "listen-address" */
@@ -367,6 +368,7 @@ struct configuration_spec * load_config(void)
    config->feature_flags            &= ~RUNTIME_FEATURE_CGI_TOGGLE;
    config->feature_flags            &= ~RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
    config->feature_flags            &= ~RUNTIME_FEATURE_ACCEPT_INTERCEPTED_REQUESTS;
    config->feature_flags            &= ~RUNTIME_FEATURE_CGI_TOGGLE;
    config->feature_flags            &= ~RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
    config->feature_flags            &= ~RUNTIME_FEATURE_ACCEPT_INTERCEPTED_REQUESTS;
+   config->feature_flags            &= ~RUNTIME_FEATURE_EMPTY_DOC_RETURNS_OK;
 
    configfp = fopen(configfile, "r");
    if (NULL == configfp)
 
    configfp = fopen(configfile, "r");
    if (NULL == configfp)
@@ -911,6 +913,26 @@ struct configuration_spec * load_config(void)
             config->forwarded_connect_retries = atoi(arg);
             break;
 
             config->forwarded_connect_retries = atoi(arg);
             break;
 
+/* *************************************************************************
+ * handle-as-empty-doc-returns-ok 0|1
+ *
+ * Workaround for firefox hanging on blocked javascript pages.
+ *   Block with the "+handle-as-empty-document" flag and set the
+ *   "handle-as-empty-doc-returns-ok" run-time config flag so that
+ *   Privoxy returns a 200/OK status instead of a 403/Forbidden status
+ *   to the browser for blocked pages.
+ ***************************************************************************/
+         case hash_handle_as_empty_returns_ok:
+            if ((*arg != '\0') && (0 != atoi(arg)))
+            {
+               config->feature_flags |= RUNTIME_FEATURE_EMPTY_DOC_RETURNS_OK;
+            }
+            else
+            {
+               config->feature_flags &= ~RUNTIME_FEATURE_EMPTY_DOC_RETURNS_OK;
+            }
+            break;
+
 /* *************************************************************************
  * hostname hostname-to-show-on-cgi-pages
  * *************************************************************************/
 /* *************************************************************************
  * hostname hostname-to-show-on-cgi-pages
  * *************************************************************************/
index ae80b49..e5c076d 100644 (file)
--- a/project.h
+++ b/project.h
@@ -1,7 +1,7 @@
 #ifndef PROJECT_H_INCLUDED
 #define PROJECT_H_INCLUDED
 /** Version string. */
 #ifndef PROJECT_H_INCLUDED
 #define PROJECT_H_INCLUDED
 /** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.152 2009/11/08 17:54:09 ler762 Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.153 2009/11/27 13:46:47 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/project.h,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/project.h,v $
@@ -1148,6 +1148,9 @@ struct access_control_list
 /** configuration_spec::feature_flags: Share outgoing connections between different client connections. */
 #define RUNTIME_FEATURE_CONNECTION_SHARING         256U
 
 /** configuration_spec::feature_flags: Share outgoing connections between different client connections. */
 #define RUNTIME_FEATURE_CONNECTION_SHARING         256U
 
+/** configuration_spec::feature_flags: Pages blocked with +handle-as-empty-doc get a return status of 200 OK. */
+#define RUNTIME_FEATURE_EMPTY_DOC_RETURNS_OK       512U
+
 /**
  * Data loaded from the configuration file.
  *
 /**
  * Data loaded from the configuration file.
  *
@@ -1174,6 +1177,7 @@ struct configuration_spec
     * - RUNTIME_FEATURE_CGI_CRUNCHING
     * - RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE
     * - RUNTIME_FEATURE_CONNECTION_SHARING
     * - RUNTIME_FEATURE_CGI_CRUNCHING
     * - RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE
     * - RUNTIME_FEATURE_CONNECTION_SHARING
+    * - RUNTIME_FEATURE_EMPTY_DOC_RETURNS_OK
     */
    unsigned feature_flags;
 
     */
    unsigned feature_flags;