From 6147ca54a454838e00dfa108db5b13ec10b9aa2f Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 25 Jul 2002 07:45:01 +0000 Subject: Do some minimalistic validation of command-lines (ie, make sure it isn't 2002-07-25 Jeffrey Stedfast * filter-file.c (validate): Do some minimalistic validation of command-lines (ie, make sure it isn't an empty string). * filtertypes.xml: s/shell-exec/shell/ (for the action) and pass "/bin/sh" "-c" as the first 2 arguments. For the shell-exec *rule*, change the name to "pipe-message" and add the "/bin/sh" "-c" arguments too. svn path=/trunk/; revision=17584 --- filter/ChangeLog | 10 ++++++++++ filter/filter-file.c | 14 +++++++++----- filter/filtertypes.xml | 26 +++++++++++++------------- filter/libfilter-i18n.h | 8 ++++++-- 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/filter/ChangeLog b/filter/ChangeLog index 59309cd4a6..95b02e0d4f 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,13 @@ +2002-07-25 Jeffrey Stedfast + + * filter-file.c (validate): Do some minimalistic validation of + command-lines (ie, make sure it isn't an empty string). + + * filtertypes.xml: s/shell-exec/shell/ (for the action) and pass + "/bin/sh" "-c" as the first 2 arguments. For the shell-exec + *rule*, change the name to "pipe-message" and add the "/bin/sh" + "-c" arguments too. + 2002-07-17 Jeffrey Stedfast * filter-label.c (xml_create): Use the U_() macro to get the UTF-8 diff --git a/filter/filter-file.c b/filter/filter-file.c index b34dd0f773..14f8e04d5b 100644 --- a/filter/filter-file.c +++ b/filter/filter-file.c @@ -181,29 +181,34 @@ validate (FilterElement *fe) return FALSE; } - /* FIXME: validate command-lines? */ + /* FIXME: do more to validate command-lines? */ if (strcmp (file->type, "file") != 0) { if (stat (file->path, &st) == -1 || !S_ISREG (st.st_mode)) { char *errmsg; - errmsg = g_strdup_printf (_("File '%s' does not exist or is not a regular file."), file->path); + errmsg = g_strdup_printf (_("File '%s' does not exist or is not a regular file."), + file->path); dialog = gnome_ok_dialog (errmsg); g_free (errmsg); gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); return FALSE; } + } else if (strcmp (file->type, "command") != 0) { + /* only requirements so far is that the command can't + be an empty string */ + return file->path[0] != '\0'; } return TRUE; } static int -file_eq(FilterElement *fe, FilterElement *cm) +file_eq (FilterElement *fe, FilterElement *cm) { FilterFile *ff = (FilterFile *)fe, *cf = (FilterFile *)cm; - + return ((FilterElementClass *)(parent_class))->eq(fe, cm) && ((ff->path && cf->path && strcmp(ff->path, cf->path) == 0) || (ff->path == NULL && cf->path == NULL)) @@ -216,7 +221,6 @@ xml_create (FilterElement *fe, xmlNodePtr node) { /* parent implementation */ ((FilterElementClass *)(parent_class))->xml_create (fe, node); - } static xmlNodePtr diff --git a/filter/filtertypes.xml b/filter/filtertypes.xml index 7c0690cfa0..67b7f9a6d3 100644 --- a/filter/filtertypes.xml +++ b/filter/filtertypes.xml @@ -581,32 +581,32 @@ - - Command + + Pipe Message to Shell Command @@ -682,9 +682,9 @@ (play-sound ${sound}) - - Execute Shell Command - (shell-exec ${command}) + + Shell Command + (shell "/bin/sh" "-c" ${command}) diff --git a/filter/libfilter-i18n.h b/filter/libfilter-i18n.h index 9d930d930b..4f5d253af5 100644 --- a/filter/libfilter-i18n.h +++ b/filter/libfilter-i18n.h @@ -4,7 +4,6 @@ char *s = N_("Assign Color"); char *s = N_("Assign Score"); char *s = N_("Attachments"); char *s = N_("Beep"); -char *s = N_("Command"); char *s = N_("contains"); char *s = N_("Copy to Folder"); char *s = N_("Date received"); @@ -14,12 +13,12 @@ char *s = N_("Deleted"); char *s = N_("does not contain"); char *s = N_("does not end with"); char *s = N_("does not exist"); +char *s = N_("does not return"); char *s = N_("does not sound like"); char *s = N_("does not start with"); char *s = N_("Do Not Exist"); char *s = N_("Draft"); char *s = N_("ends with"); -char *s = N_("Execute Shell Command"); char *s = N_("Exist"); char *s = N_("exists"); char *s = N_("Expression"); @@ -38,14 +37,19 @@ char *s = N_("Mailing list"); char *s = N_("Message Body"); char *s = N_("Message Header"); char *s = N_("Move to Folder"); +char *s = N_("Pipe Message to Shell Command"); char *s = N_("Play Sound"); char *s = N_("Read"); char *s = N_("Recipients"); char *s = N_("Regex Match"); char *s = N_("Replied to"); +char *s = N_("returns"); +char *s = N_("returns greater than"); +char *s = N_("returns less than"); char *s = N_("Score"); char *s = N_("Sender"); char *s = N_("Set Status"); +char *s = N_("Shell Command"); char *s = N_("Size (kB)"); char *s = N_("sounds like"); char *s = N_("Source Account"); -- cgit v1.2.3