X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=loadcfg.c;h=899e43098d500f3551032f9142d8e57266be95e1;hp=b5512d7c122c713cf26bf26077d8786a0ea0e6d5;hb=f3e87d9a4e656286a271d5ad822d65301e2ef0f4;hpb=140da2f315c69184c96dc753c8d1ae872f19cfc2 diff --git a/loadcfg.c b/loadcfg.c index b5512d7c..899e4309 100644 --- 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.111 2010/08/14 23:28:52 ler762 Exp $"; /********************************************************************* * * 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_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" */ @@ -247,11 +248,6 @@ static void unload_configfile (void * data) list_remove_all(config->trust_info); #endif /* def FEATURE_TRUST */ - for (i = 0; i < MAX_AF_FILES; i++) - { - freez(config->re_filterfile[i]); - } - freez(config); } @@ -296,7 +292,7 @@ void unload_current_config_file(void) *********************************************************************/ struct configuration_spec * load_config(void) { - char buf[BUFFER_SIZE]; + char *buf = NULL; char *p, *q; FILE *configfp = NULL; struct configuration_spec * config = NULL; @@ -367,6 +363,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_EMPTY_DOC_RETURNS_OK; configfp = fopen(configfile, "r"); if (NULL == configfp) @@ -376,7 +373,7 @@ struct configuration_spec * load_config(void) /* Never get here - LOG_LEVEL_FATAL causes program exit */ } - while (read_config_line(buf, sizeof(buf), configfp, &linenum) != NULL) + while (read_config_line(configfp, &linenum, &buf) != NULL) { char cmd[BUFFER_SIZE]; char arg[BUFFER_SIZE]; @@ -407,11 +404,15 @@ struct configuration_spec * load_config(void) } /* Copy the argument into arg */ - strlcpy(arg, p, sizeof(arg)); + if (strlcpy(arg, p, sizeof(arg)) >= sizeof(arg)) + { + log_error(LOG_LEVEL_FATAL, "Config line too long: %s", buf); + } /* Should never happen, but check this anyway */ if (*cmd == '\0') { + freez(buf); continue; } @@ -911,6 +912,26 @@ struct configuration_spec * load_config(void) 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 * *************************************************************************/ @@ -1322,7 +1343,7 @@ struct configuration_spec * load_config(void) /* Save the argument for the show-status page. */ savearg(cmd, arg, config); - + freez(buf); } /* end while ( read_config_line(...) ) */ fclose(configfp); @@ -1462,8 +1483,9 @@ struct configuration_spec * load_config(void) #if defined(_WIN32) && !defined (_WIN_CONSOLE) g_default_actions_file = config->actions_file[1]; /* FIXME Hope this is default.action */ - g_user_actions_file = config->actions_file[2]; /* FIXME Hope this is user.action */ - g_re_filterfile = config->re_filterfile[0]; /* FIXME Hope this is default.filter */ + g_user_actions_file = config->actions_file[2]; /* FIXME Hope this is user.action */ + g_default_filterfile = config->re_filterfile[0]; /* FIXME Hope this is default.filter */ + g_user_filterfile = config->re_filterfile[1]; /* FIXME Hope this is user.filter */ #ifdef FEATURE_TRUST g_trustfile = config->trustfile;