X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=cgiedit.c;h=e4f1d68fd2546befaeff2b974411e2f5b4d28a0d;hp=5cd0fb31ae76d0742904bf794d0388018a2a6387;hb=41d37e938e75b5eaa032257fa1979f145d403b74;hpb=eaf38167c9a21326865db5cbb021b11abdfbc496 diff --git a/cgiedit.c b/cgiedit.c index 5cd0fb31..e4f1d68f 100644 --- a/cgiedit.c +++ b/cgiedit.c @@ -1,4 +1,4 @@ -const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.43 2006/07/18 14:48:45 david__schmidt Exp $"; +const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.47 2006/12/28 18:04:25 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgiedit.c,v $ @@ -15,7 +15,7 @@ const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.43 2006/07/18 14:48:45 david__sch * * Stick to the short names in this file for consistency. * - * Copyright : Written by and Copyright (C) 2001 the SourceForge + * Copyright : Written by and Copyright (C) 2001-2007 the SourceForge * Privoxy team. http://www.privoxy.org/ * * Based on the Internet Junkbuster originally written @@ -42,6 +42,21 @@ const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.43 2006/07/18 14:48:45 david__sch * * Revisions : * $Log: cgiedit.c,v $ + * Revision 1.47 2006/12/28 18:04:25 fabiankeil + * Fixed gcc43 conversion warnings. + * + * Revision 1.46 2006/12/27 18:44:52 fabiankeil + * Stop shadowing string.h's index(). + * + * Revision 1.45 2006/12/21 12:57:48 fabiankeil + * Add config option "split-large-forms" + * to work around the browser bug reported + * in BR #1570678. + * + * Revision 1.44 2006/12/09 13:49:16 fabiankeil + * Fix configure option --disable-toggle. + * Thanks to Peter Thoenen for reporting this. + * * Revision 1.43 2006/07/18 14:48:45 david__schmidt * Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch) * with what was really the latest development (the v_3_0_branch branch) @@ -986,7 +1001,7 @@ jb_err edit_write_file(struct editable_file * file) { /* Must quote '#' characters */ int numhash = 0; - int len; + size_t len; char * src; char * dest; char * str; @@ -1001,29 +1016,44 @@ jb_err edit_write_file(struct editable_file * file) assert(numhash > 0); /* Allocate new memory for string */ - len = strlen(cur_line->unprocessed); - if (NULL == (str = malloc((size_t) len + 1 + numhash))) + len = strlen(cur_line->unprocessed) + (size_t)numhash; + if (NULL == (str = malloc(len + 1))) { /* Uh oh, just trashed file! */ fclose(fp); return JB_ERR_MEMORY; } - /* Loop through string from end */ - src = cur_line->unprocessed + len; - dest = str + len + numhash; - for ( ; len >= 0; len--) + /* Copy string but quote hashes */ + src = cur_line->unprocessed; + dest = str; + while (*src) { - if ((*dest-- = *src--) == '#') + if (*src == '#') { - *dest-- = '\\'; + *dest++ = '\\'; numhash--; assert(numhash >= 0); } + *dest++ = *src++; } + *dest = '\0'; + assert(numhash == 0); - assert(src + 1 == cur_line->unprocessed); - assert(dest + 1 == str); + assert(strlen(str) == len); + assert(str == dest - len); + assert(src - len <= cur_line->unprocessed); + + if ((strlen(str) != len) || (numhash != 0)) + { + /* + * Escaping didn't work as expected, go spread the news. + * Only reached in non-debugging builds. + */ + log_error(LOG_LEVEL_ERROR, + "Looks like hash escaping failed. %s might be corrupted now.", + file->filename); + } if (fputs(str, fp) < 0) { @@ -1284,7 +1314,7 @@ static jb_err split_line_on_equals(const char * line, char ** pname, char ** pva name_end--; } - name_len = name_end - line + 1; /* Length excluding \0 */ + name_len = (size_t)(name_end - line) + 1; /* Length excluding \0 */ if (NULL == (*pname = (char *) malloc(name_len + 1))) { return JB_ERR_MEMORY; @@ -1980,7 +2010,7 @@ static jb_err get_file_name_param(struct client_state *csp, char *name; char *fullpath; char ch; - int len; + size_t len; assert(csp); assert(parameters); @@ -2237,7 +2267,7 @@ static jb_err map_radio(struct map * exports, } } - *p = value; + *p = (char)value; return map(exports, buf, 0, "checked", 1); } @@ -3029,6 +3059,35 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp, if (!err) err = actions_to_radio(exports, cur_line->data.action); + /* + * XXX: Some browsers (at least IE6 and IE7) have an artifical URL + * length limitation and ignore clicks on the Submit buttons if + * the resulting GET URL would be longer than their limit. + * + * In Privoxy 3.0.5 beta the standard edit-actions-for-url template + * reached this limit and action editing stopped working in these + * browsers (BR #1570678). + * + * The config option split-large-forms works around this browser + * bug (HTTP has no URL lenght limitation) by deviding the action + * list form into multiple smaller ones. It means the URLs are shorter + * and work in broken browsers as well, but the user can no longer change + * all actions with one submit. + * + * A better solution would be to switch to POST requests, + * but this will do for now. + */ + if(!err && (csp->config->feature_flags & RUNTIME_FEATURE_SPLIT_LARGE_FORMS)) + { + /* Generate multiple smaller form by killing the big one. */ + err = map_block_killer(exports, "one-form-only"); + } + else + { + /* Default: Generate one large form by killing the smaller ones. */ + err = map_block_killer(exports, "multiple-forms"); + } + for (i = 0; i < MAX_AF_FILES; i++) { if ((csp->rlist[i] != NULL) && (csp->rlist[i]->f != NULL)) @@ -3052,7 +3111,7 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp, { /* We have some entries in the filter list */ char * result; - int index = 0; + int filter_identifier = 0; char * filter_template; err = template_load(csp, &filter_template, "edit-actions-for-url-filter", 0); @@ -3110,7 +3169,7 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp, } /* Generate a unique serial number */ - snprintf(number, sizeof(number), "%x", index++); + snprintf(number, sizeof(number), "%x", filter_identifier++); number[sizeof(number) - 1] = '\0'; line_exports = new_map(); @@ -3199,7 +3258,7 @@ jb_err cgi_edit_actions_submit(struct client_state *csp, unsigned line_number; char target[1024]; jb_err err; - int index; + int filter_identifier; const char * action_set_name; char ch; struct file_list * fl; @@ -3243,9 +3302,9 @@ jb_err cgi_edit_actions_submit(struct client_state *csp, get_string_param(parameters, "p", &action_set_name); if (action_set_name != NULL) { - for (index = 0; index < MAX_AF_FILES; index++) + for (filter_identifier = 0; filter_identifier < MAX_AF_FILES; filter_identifier++) { - if (((fl = csp->actions_list[index]) != NULL) && ((b = fl->f) != NULL)) + if (((fl = csp->actions_list[filter_identifier]) != NULL) && ((b = fl->f) != NULL)) { for (b = b->next; NULL != b; b = b->next) { @@ -3286,7 +3345,7 @@ jb_err cgi_edit_actions_submit(struct client_state *csp, cur_line->data.action->multi_remove_all[ACTION_MULTI_FILTER] = 0; } - for (index = 0; !err; index++) + for (filter_identifier = 0; !err; filter_identifier++) { char key_value[30]; char key_name[30]; @@ -3294,9 +3353,9 @@ jb_err cgi_edit_actions_submit(struct client_state *csp, char value; /* Generate the keys */ - snprintf(key_value, sizeof(key_value), "filter_r%x", index); + snprintf(key_value, sizeof(key_value), "filter_r%x", filter_identifier); key_value[sizeof(key_value) - 1] = '\0'; - snprintf(key_name, sizeof(key_name), "filter_n%x", index); + snprintf(key_name, sizeof(key_name), "filter_n%x", filter_identifier); key_name[sizeof(key_name) - 1] = '\0'; err = get_string_param(parameters, key_name, &name);