X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=parsers.c;h=5ff9eea9503b58880b00cdbb9587a2b610f6738b;hp=d5219715c9785b6a2f271d7f72982ed863e365ba;hb=1d2a21ed0350fd3cad3b8e08f9c72fd3404d5c3b;hpb=b2f697fb80d71f3c63af71f3cba0ab233aeafe4d diff --git a/parsers.c b/parsers.c index d5219715..5ff9eea9 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.117 2007/12/06 18:11:50 fabiankeil Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.122 2008/03/28 15:13:39 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -44,6 +44,31 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.117 2007/12/06 18:11:50 fabiankei * * Revisions : * $Log: parsers.c,v $ + * Revision 1.122 2008/03/28 15:13:39 fabiankeil + * Remove inspect-jpegs action. + * + * Revision 1.121 2008/01/05 21:37:03 fabiankeil + * Let client_range() also handle Request-Range headers + * which apparently are still supported by many servers. + * + * Revision 1.120 2008/01/04 17:43:45 fabiankeil + * Improve the warning messages that get logged if the action files + * "enable" filters but no filters of that type have been loaded. + * + * Revision 1.119 2007/12/28 18:32:51 fabiankeil + * In server_content_type(): + * - Don't require leading white space when detecting image content types. + * - Change '... not replaced ...' message to sound less crazy if the text + * type actually is 'text/plain'. + * - Mark the 'text/plain == binary data' assumption for removal. + * - Remove a bunch of trailing white space. + * + * Revision 1.118 2007/12/28 16:56:35 fabiankeil + * Minor server_content_disposition() changes: + * - Don't regenerate the header name all lower-case. + * - Some white space fixes. + * - Remove useless log message in case of ENOMEM. + * * Revision 1.117 2007/12/06 18:11:50 fabiankeil * Garbage-collect the code to add a X-Forwarded-For * header as it seems to be mostly used by accident. @@ -831,7 +856,6 @@ static jb_err server_last_modified (struct client_state *csp, char **header static jb_err server_content_disposition(struct client_state *csp, char **header); static jb_err client_host_adder (struct client_state *csp); -static jb_err client_cookie_adder (struct client_state *csp); static jb_err client_xtra_adder (struct client_state *csp); static jb_err connection_close_adder (struct client_state *csp); @@ -858,6 +882,7 @@ const struct parsers client_patterns[] = { { "Accept-Language:", 16, client_accept_language }, { "if-none-match:", 14, client_if_none_match }, { "Range:", 6, client_range }, + { "Request-Range:", 14, client_range }, { "If-Range:", 9, client_range }, { "X-Filter:", 9, client_x_filter }, { "*", 0, crunch_client_header }, @@ -892,7 +917,6 @@ const struct parsers server_patterns_light[] = { const add_header_func_ptr add_client_headers[] = { client_host_adder, - client_cookie_adder, client_xtra_adder, /* Temporarily disabled: client_accept_encoding_adder, */ connection_close_adder, @@ -904,16 +928,6 @@ const add_header_func_ptr add_server_headers[] = { NULL }; -/* The vanilla wafer. */ -static const char VANILLA_WAFER[] = - "NOTICE=TO_WHOM_IT_MAY_CONCERN_" - "Do_not_send_me_any_copyrighted_information_other_than_the_" - "document_that_I_am_requesting_or_any_of_its_necessary_components._" - "In_particular_do_not_send_me_any_cookies_that_" - "are_subject_to_a_claim_of_copyright_by_anybody._" - "Take_notice_that_I_refuse_to_be_bound_by_any_license_condition_" - "(copyright_or_otherwise)_applying_to_any_cookie._"; - /********************************************************************* * * Function : flush_socket @@ -1689,7 +1703,8 @@ static jb_err header_tagger(struct client_state *csp, char *header) if (0 == found_filters) { - log_error(LOG_LEVEL_ERROR, "Unable to get current state of regex tagging."); + log_error(LOG_LEVEL_ERROR, "Inconsistent configuration: " + "tagging enabled, but no taggers available."); return(JB_ERR_OK); } @@ -1906,7 +1921,8 @@ static jb_err filter_header(struct client_state *csp, char **header) if (0 == found_filters) { - log_error(LOG_LEVEL_ERROR, "Unable to get current state of regexp filtering."); + log_error(LOG_LEVEL_ERROR, "Inconsistent configuration: " + "header filtering enabled, but no matching filters available."); return(JB_ERR_OK); } @@ -2172,39 +2188,40 @@ static jb_err server_content_type(struct client_state *csp, char **header) if (!(csp->content_type & CT_TABOO)) { - if ((strstr(*header, " text/") && !strstr(*header, "plain")) + /* + * XXX: The assumption that text/plain is a sign of + * binary data seems to be somewhat unreasonable nowadays + * and should be dropped after 3.0.8 is out. + */ + if ((strstr(*header, "text/") && !strstr(*header, "plain")) || strstr(*header, "xml") || strstr(*header, "application/x-javascript")) { csp->content_type |= CT_TEXT; } - else if (strstr(*header, " image/gif")) + else if (strstr(*header, "image/gif")) { csp->content_type |= CT_GIF; } - else if (strstr(*header, " image/jpeg")) - { - csp->content_type |= CT_JPEG; - } } /* * Are we messing with the content type? - */ + */ if (csp->action->flags & ACTION_CONTENT_TYPE_OVERWRITE) - { + { /* * Make sure the user doesn't accidently * change the content type of binary documents. - */ + */ if ((csp->content_type & CT_TEXT) || (csp->action->flags & ACTION_FORCE_TEXT_MODE)) - { + { freez(*header); *header = strdup("Content-Type: "); string_append(header, csp->action->string[ACTION_STRING_CONTENT_TYPE]); if (header == NULL) - { + { log_error(LOG_LEVEL_HEADER, "Insufficient memory to replace Content-Type!"); return JB_ERR_MEMORY; } @@ -2212,10 +2229,11 @@ static jb_err server_content_type(struct client_state *csp, char **header) } else { - log_error(LOG_LEVEL_HEADER, "%s not replaced. It doesn't look like text. " - "Enable force-text-mode if you know what you're doing.", *header); + log_error(LOG_LEVEL_HEADER, "%s not replaced. " + "It doesn't look like a content type that should be filtered. " + "Enable force-text-mode if you know what you're doing.", *header); } - } + } return JB_ERR_OK; } @@ -3428,9 +3446,9 @@ jb_err client_x_filter(struct client_state *csp, char **header) * * Function : client_range * - * Description : Removes Range and If-Range headers if content - * filtering is enabled. If the client's version of - * the document has been altered by Privoxy, the server + * Description : Removes Range, Request-Range and If-Range headers if + * content filtering is enabled. If the client's version + * of the document has been altered by Privoxy, the server * could interpret the range differently than the client * intended in which case the user could end up with * corrupted content. @@ -3511,69 +3529,6 @@ static jb_err client_host_adder(struct client_state *csp) } -/********************************************************************* - * - * Function : client_cookie_adder - * - * Description : Used in the add_client_headers list to add "wafers". - * Called from `sed'. - * - * Parameters : - * 1 : csp = Current client state (buffers, headers, etc...) - * - * Returns : JB_ERR_OK on success, or - * JB_ERR_MEMORY on out-of-memory error. - * - *********************************************************************/ -jb_err client_cookie_adder(struct client_state *csp) -{ - char *tmp; - struct list_entry *wafer; - struct list_entry *wafer_list; - jb_err err; - - /* - * If the user has not supplied any wafers, and the user has not - * told us to suppress the vanilla wafer, then send the vanilla wafer. - */ - if ((0 != (csp->action->flags & ACTION_VANILLA_WAFER)) - && list_is_empty(csp->action->multi[ACTION_MULTI_WAFER])) - { - enlist(csp->action->multi[ACTION_MULTI_WAFER], VANILLA_WAFER); - } - - wafer_list = csp->action->multi[ACTION_MULTI_WAFER]->first; - - if (NULL == wafer_list) - { - /* Nothing to do */ - return JB_ERR_OK; - } - - tmp = strdup("Cookie: "); - - for (wafer = wafer_list; (NULL != tmp) && (NULL != wafer); wafer = wafer->next) - { - if (wafer != wafer_list) - { - /* As this isn't the first wafer, we need a delimiter. */ - string_append(&tmp, "; "); - } - string_join(&tmp, cookie_encode(wafer->str)); - } - - if (tmp == NULL) - { - return JB_ERR_MEMORY; - } - - log_error(LOG_LEVEL_HEADER, "addh: %s", tmp); - err = enlist(csp->headers, tmp); - free(tmp); - return err; -} - - #if 0 /********************************************************************* *