-const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.74 2012/03/09 16:24:36 fabiankeil Exp $";
+const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.81 2014/06/02 06:22:20 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-2008 the SourceForge
+ * Copyright : Written by and Copyright (C) 2001-2014 the
* Privoxy team. http://www.privoxy.org/
*
* Based on the Internet Junkbuster originally written
} setting;
- /* Add more data types here... e.g.
-
-
- struct url_spec url[1];
-
- struct
- {
- struct action_spec action[1];
- const char * name;
- } alias;
-
- */
-
} data;
};
"server-header-tagger-all", "server_header_tagger_all",
"E", "SERVER-HEADER-TAGGER"
},
+#ifdef FEATURE_EXTERNAL_FILTERS
+ {
+ ACTION_MULTI_EXTERNAL_FILTER,
+ "external-content-filter-params", "external-filter",
+ "external-content-filter-all", "external_content_filter_all",
+ "E", "EXTERNAL-CONTENT-FILTER"
+ },
+#endif
};
/* FIXME: Following non-static functions should be prototyped in .h or made static */
{
char buf[30];
- snprintf(buf, sizeof(buf), "#l%d", sectionid);
+ snprintf(buf, sizeof(buf), "#l%u", sectionid);
return(strdup(buf));
}
{
char buf[6];
- snprintf(buf, sizeof(buf), "%i", number);
+ snprintf(buf, sizeof(buf), "%u", number);
return strdup(buf);
}
/* Allocate new memory for string */
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;
- }
+ str = malloc_or_die(len + 1);
/* Copy string but quote hashes */
src = cur_line->unprocessed;
}
name_len = (size_t)(name_end - line) + 1; /* Length excluding \0 */
- if (NULL == (*pname = (char *) malloc(name_len + 1)))
- {
- return JB_ERR_MEMORY;
- }
+ *pname = malloc_or_die(name_len + 1);
strncpy(*pname, line, name_len);
(*pname)[name_len] = '\0';
cur_line->type = FILE_LINE_ACTION;
/* Remove {} and make copy */
- if (NULL == (value = (char *) malloc(len + 1)))
- {
- /* Out of memory */
- free_alias_list(alias_list);
- return JB_ERR_MEMORY;
- }
+ value = malloc_or_die(len + 1);
strncpy(value, text, len);
value[len] = '\0';
/* Append extension */
name_size = len + strlen(suffix) + 1;
- name = malloc(name_size);
- if (name == NULL)
- {
- return JB_ERR_MEMORY;
- }
+ name = malloc_or_die(name_size);
strlcpy(name, param, name_size);
strlcat(name, suffix, name_size);
const char *orig_param;
char *param;
char *s;
- struct url_spec compiled[1];
+ struct pattern_spec compiled[1];
jb_err err;
assert(csp);
free(param);
return JB_ERR_MEMORY;
}
- err = create_url_spec(compiled, s);
+ err = create_pattern_spec(compiled, s);
free(s);
if (err)
{
free(param);
return (err == JB_ERR_MEMORY) ? JB_ERR_MEMORY : JB_ERR_CGI_PARAMS;
}
- free_url_spec(compiled);
+ free_pattern_spec(compiled);
if (param[strlen(param) - 1] == '\\')
{
free(param);
return JB_ERR_MEMORY;
}
- err = create_url_spec(compiled, s);
+ err = create_pattern_spec(compiled, s);
free(s);
if (err)
{
free(param);
return (err == JB_ERR_MEMORY) ? JB_ERR_MEMORY : JB_ERR_CGI_PARAMS;
}
- free_url_spec(compiled);
+ free_pattern_spec(compiled);
}
*pvalue = param;
assert(optionname);
assert(values);
- buf = malloc(buf_size);
- if (buf == NULL)
- {
- return JB_ERR_MEMORY;
- }
+ buf = malloc_or_die(buf_size);
strlcpy(buf, optionname, buf_size);
*/
if (!err) err = map_conditional(exports, "all-urls-present", 1);
- snprintf(buf, sizeof(buf), "%d", line_number);
+ snprintf(buf, sizeof(buf), "%u", line_number);
if (!err) err = map(exports, "all-urls-s", 1, buf, 1);
- snprintf(buf, sizeof(buf), "%d", line_number + 2);
+ snprintf(buf, sizeof(buf), "%u", line_number + 2);
if (!err) err = map(exports, "all-urls-s-next", 1, buf, 1);
if (!err) err = map(exports, "all-urls-actions", 1,
actions_to_html(csp, cur_line->data.action), 0);
return JB_ERR_MEMORY;
}
- snprintf(buf, sizeof(buf), "%d", line_number);
+ snprintf(buf, sizeof(buf), "%u", line_number);
err = map(section_exports, "s", 1, buf, 1);
if (!err) err = map(section_exports, "actions", 1,
actions_to_html(csp, cur_line->data.action), 0);
if (prev_section_line_number != ((unsigned)(-1)))
{
/* Not last section */
- snprintf(buf, sizeof(buf), "%d", prev_section_line_number);
+ snprintf(buf, sizeof(buf), "%u", prev_section_line_number);
if (!err) err = map(section_exports, "s-prev", 1, buf, 1);
if (!err) err = map_block_keep(section_exports, "s-prev-exists");
}
return JB_ERR_MEMORY;
}
- snprintf(buf, sizeof(buf), "%d", line_number);
+ snprintf(buf, sizeof(buf), "%u", line_number);
err = map(url_exports, "p", 1, buf, 1);
snprintf(buf, sizeof(buf), "%d", url_1_2);
/* Could also do section-specific exports here, but it wouldn't be as fast */
- snprintf(buf, sizeof(buf), "%d", line_number);
+ snprintf(buf, sizeof(buf), "%u", line_number);
if (!err) err = map(section_exports, "s-next", 1, buf, 1);
if ((cur_line != NULL)
}
}
+#ifndef FEATURE_EXTERNAL_FILTERS
+ if (!err) err = map_block_killer(exports, "external-content-filters");
+#endif
+
if (err)
{
edit_free_file(file);
}
newtext_size = len + 2;
- if (NULL == (newtext = malloc(newtext_size)))
- {
- /* Out of memory */
- free(actiontext);
- edit_free_file(file);
- return JB_ERR_MEMORY;
- }
+ newtext = malloc_or_die(newtext_size);
strlcpy(newtext, actiontext, newtext_size);
free(actiontext);
newtext[0] = '{';
return err;
}
- snprintf(target, sizeof(target), CGI_PREFIX "edit-actions-list?foo=%lu&f=%i#l%d",
+ snprintf(target, sizeof(target), CGI_PREFIX "edit-actions-list?foo=%lu&f=%i#l%u",
(long) time(NULL), file->identifier, sectionid);
edit_free_file(file);
return err;
}
- snprintf(target, sizeof(target), CGI_PREFIX "edit-actions-list?foo=%lu&f=%i#l%d",
+ snprintf(target, sizeof(target), CGI_PREFIX "edit-actions-list?foo=%lu&f=%i#l%u",
(long) time(NULL), file->identifier, section_start_line_number);
edit_free_file(file);
return err;
}
- snprintf(target, sizeof(target), CGI_PREFIX "edit-actions-list?foo=%lu&f=%i#l%d",
+ snprintf(target, sizeof(target), CGI_PREFIX "edit-actions-list?foo=%lu&f=%i#l%u",
(long) time(NULL), file->identifier, sectionid);
edit_free_file(file);
return err;
}
- snprintf(target, sizeof(target), CGI_PREFIX "edit-actions-list?foo=%lu&f=%i#l%d",
+ snprintf(target, sizeof(target), CGI_PREFIX "edit-actions-list?foo=%lu&f=%u#l%u",
(long) time(NULL), file->identifier, section_start_line_number);
edit_free_file(file);
return err;
}
- snprintf(target, sizeof(target), CGI_PREFIX "edit-actions-list?foo=%lu&f=%i",
+ snprintf(target, sizeof(target), CGI_PREFIX "edit-actions-list?foo=%lu&f=%u",
(long) time(NULL), file->identifier);
edit_free_file(file);
return err;
}
- snprintf(target, sizeof(target), CGI_PREFIX "edit-actions-list?foo=%lu&f=%i",
+ snprintf(target, sizeof(target), CGI_PREFIX "edit-actions-list?foo=%lu&f=%u",
(long) time(NULL), file->identifier);
edit_free_file(file);
}
} /* END if (section1 != section2) */
- snprintf(target, sizeof(target), CGI_PREFIX "edit-actions-list?foo=%lu&f=%i",
+ snprintf(target, sizeof(target), CGI_PREFIX "edit-actions-list?foo=%lu&f=%u",
(long) time(NULL), file->identifier);
edit_free_file(file);