-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 $
*
* 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
*
* 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)
{
/* Must quote '#' characters */
int numhash = 0;
- int len;
+ size_t len;
char * src;
char * dest;
char * str;
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)
{
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;
char *name;
char *fullpath;
char ch;
- int len;
+ size_t len;
assert(csp);
assert(parameters);
}
}
- *p = value;
+ *p = (char)value;
return map(exports, buf, 0, "checked", 1);
}
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))
{
/* 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);
}
/* 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();
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;
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)
{
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];
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);