X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=filters.c;h=e9e227c7f67b5501918cf177b02285b085d5ccb6;hb=c26bc91d76e11f9d6d1457b43b82404029f9a054;hp=df3b3f85014b27a7835e45b3ce2a3f1627ff14f9;hpb=0ecab5df27ce9d5aa8c03580e7598fce8264534a;p=privoxy.git diff --git a/filters.c b/filters.c index df3b3f85..e9e227c7 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.184 2014/06/03 10:33:17 fabiankeil Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.189 2014/10/18 11:26:18 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -1131,14 +1131,8 @@ char *get_last_url(char *subject, const char *redirect_mode) } if (NULL != url_segment) { - url_segment = strdup(url_segment); + url_segment = strdup_or_die(url_segment); freez(dtoken); - if (url_segment == NULL) - { - log_error(LOG_LEVEL_ERROR, - "Out of memory while searching for redirects."); - return NULL; - } break; } freez(dtoken); @@ -1876,6 +1870,7 @@ static char *execute_external_filter(const struct client_state *csp, { log_error(LOG_LEVEL_ERROR, "fwrite(..., %d, 1, ..) failed: %E", *size); unlink(file_name); + fclose(fp); return NULL; } fclose(fp); @@ -2064,7 +2059,8 @@ static filter_function_ptr get_filter_function(const struct client_state *csp) * Function : remove_chunked_transfer_coding * * Description : In-situ remove the "chunked" transfer coding as defined - * in rfc2616 from a buffer. + * in RFC 7230 4.1 from a buffer. XXX: The implementation + * is neither complete nor compliant (TODO #129). * * Parameters : * 1 : buffer = Pointer to the text buffer @@ -2271,7 +2267,15 @@ char *execute_content_filters(struct client_state *csp) for (filtername = csp->action->multi[ACTION_MULTI_EXTERNAL_FILTER]->first; filtername ; filtername = filtername->next) { - content = execute_external_filter(csp, filtername->str, content, &size); + char *result = execute_external_filter(csp, filtername->str, content, &size); + if (result != NULL) + { + if (content != csp->iob->cur) + { + free(content); + } + content = result; + } } csp->flags |= CSP_FLAG_MODIFIED; csp->content_length = size; @@ -2378,7 +2382,7 @@ void apply_url_actions(struct current_action_spec *action, * Invalid syntax is fatal. * *********************************************************************/ -const static struct forward_spec *get_forward_override_settings(struct client_state *csp) +static const struct forward_spec *get_forward_override_settings(struct client_state *csp) { const char *forward_override_line = csp->action->string[ACTION_STRING_FORWARD_OVERRIDE]; char forward_settings[BUFFER_SIZE];