From: oes Date: Sun, 27 May 2001 13:19:06 +0000 (+0000) Subject: Patched Joergs solution for the content-length in. X-Git-Tag: v_2_9_9~472 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=fe49d4642ec18cec07e1554a963f6fbc41591e88 Patched Joergs solution for the content-length in. --- diff --git a/parsers.c b/parsers.c index ff58e7df..18c0a9c2 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.5 2001/05/26 00:28:36 jongfoster Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.6 2001/05/26 13:39:32 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -11,7 +11,7 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.5 2001/05/26 00:28:36 jongfoster * `client_x_forwarded_adder', `client_xtra_adder', * `content_type', `crumble', `destroy_list', `enlist', * `flush_socket', `free_http_request', `get_header', - * `list_to_text', `match', `parse_http_request', `sed', + * `list_to_text', `parse_http_request', `sed', * and `server_set_cookie'. * * Copyright : Written by and Copyright (C) 2001 the SourceForge @@ -41,6 +41,10 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.5 2001/05/26 00:28:36 jongfoster * * Revisions : * $Log: parsers.c,v $ + * 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. + * * Revision 1.5 2001/05/26 00:28:36 jongfoster * Automatic reloading of config file. * Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32). @@ -211,43 +215,6 @@ void (* const add_server_headers[])(struct client_state *) = { }; -/********************************************************************* - * - * Function : match - * - * Description : Do a `strncmpic' on every pattern in pats. - * - * Parameters : - * 1 : buf = a string to match to a list of patterns - * 2 : pats = list of strings to compare against buf. - * - * Returns : Return the matching "struct parsers *", - * or NULL if no pattern matches. - * - *********************************************************************/ -static const struct parsers *match(char *buf, const struct parsers *pats) -{ - const struct parsers *v; - - if (buf == NULL) - { - /* hit me */ - log_error(LOG_LEVEL_ERROR, "NULL parameter to match()"); - return(NULL); - } - - for (v = pats; v->str ; v++) - { - if (strncmpic(buf, v->str, v->len) == 0) - { - return(v); - } - } - return(NULL); - -} - - /********************************************************************* * * Function : flush_socket @@ -551,17 +518,24 @@ char *sed(const struct parsers pats[], void (* const more_headers[])(struct clie char *hdr; void (* const *f)(); - for (p = csp->headers->next; p ; p = p->next) + for (v = pats; v->str ; v++) { - log_error(LOG_LEVEL_HEADER, "scan: %s", p->str); - - if ((v = match(p->str, pats))) + for (p = csp->headers->next; p ; p = p->next) { - hdr = v->parser(v, p->str, csp); - freez(p->str); - p->str = hdr; - } + 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) + { + hdr = v->parser(v, p->str, csp); + freez(p->str); + p->str = hdr; + } + } } /* place any additional headers on the csp->headers list */ @@ -805,6 +779,7 @@ char *content_type(const struct parsers *v, char *s, struct client_state *csp) } #endif /* defined(PCRS) || defined(KILLPOPUPS) */ + #ifdef PCRS /********************************************************************* * @@ -823,7 +798,7 @@ 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) + if (((csp->permissions & PERMIT_RE_FILTER) != 0) && csp->is_text) { log_error(LOG_LEVEL_HEADER, "crunch!"); return(NULL); diff --git a/parsers.h b/parsers.h index b03a0cd8..7d8125a8 100644 --- a/parsers.h +++ b/parsers.h @@ -1,6 +1,6 @@ #ifndef _PARSERS_H #define _PARSERS_H -#define PARSERS_H_VERSION "$Id: parsers.h,v 1.2 2001/05/20 01:21:20 jongfoster Exp $" +#define PARSERS_H_VERSION "$Id: parsers.h,v 1.3 2001/05/26 13:39:32 jongfoster Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.h,v $ @@ -13,7 +13,7 @@ * `client_x_forwarded_adder', `client_xtra_adder', * `content_type', `crumble', `destroy_list', `enlist', * `flush_socket', `free_http_request', `get_header', - * `list_to_text', `match', `parse_http_request', `sed', + * `list_to_text', `parse_http_request', `sed', * and `server_set_cookie'. * * Copyright : Written by and Copyright (C) 2001 the SourceForge @@ -43,6 +43,10 @@ * * Revisions : * $Log: parsers.h,v $ + * Revision 1.3 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. + * * Revision 1.2 2001/05/20 01:21:20 jongfoster * Version 2.9.4 checkin. * - Merged popupfile and cookiefile, and added control over PCRS