aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-07-25 15:45:01 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-07-25 15:45:01 +0800
commit6147ca54a454838e00dfa108db5b13ec10b9aa2f (patch)
treec1eecdeca212e75521bd23e2ed7700add5206a11
parente5cd4631f66e182c67bfb45df3f8a04f08761ce2 (diff)
downloadgsoc2013-evolution-6147ca54a454838e00dfa108db5b13ec10b9aa2f.tar
gsoc2013-evolution-6147ca54a454838e00dfa108db5b13ec10b9aa2f.tar.gz
gsoc2013-evolution-6147ca54a454838e00dfa108db5b13ec10b9aa2f.tar.bz2
gsoc2013-evolution-6147ca54a454838e00dfa108db5b13ec10b9aa2f.tar.lz
gsoc2013-evolution-6147ca54a454838e00dfa108db5b13ec10b9aa2f.tar.xz
gsoc2013-evolution-6147ca54a454838e00dfa108db5b13ec10b9aa2f.tar.zst
gsoc2013-evolution-6147ca54a454838e00dfa108db5b13ec10b9aa2f.zip
Do some minimalistic validation of command-lines (ie, make sure it isn't
2002-07-25 Jeffrey Stedfast <fejj@ximian.com> * 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
-rw-r--r--filter/ChangeLog10
-rw-r--r--filter/filter-file.c14
-rw-r--r--filter/filtertypes.xml26
-rw-r--r--filter/libfilter-i18n.h8
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 <fejj@ximian.com>
+
+ * 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 <fejj@ximian.com>
* 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 @@
<input type="source" name="source"/>
</part>
- <part name="command">
- <title>Command</title>
+ <part name="pipe">
+ <title>Pipe Message to Shell Command</title>
<input type="command" name="command"/>
<input type="optionlist" name="retval-type">
<option value="is">
- <title>is</title>
+ <title>returns</title>
<code>
- (match-all (= (shell-exec ${command}) ${retval}))
+ (match-all (= (pipe-message "/bin/sh" "-c" ${command}) ${retval}))
</code>
</option>
<option value="is-not">
- <title>is not</title>
+ <title>does not return</title>
<code>
- (match-all (not (= (shell-exec ${command}) ${retval})))
+ (match-all (not (= (pipe-message "/bin/sh" "-c" ${command}) ${retval})))
</code>
</option>
<option value="greater-than">
- <title>is greater than</title>
+ <title>returns greater than</title>
<code>
- (match-all (&gt; (shell-exec ${command}) ${retval}))
+ (match-all (&gt; (pipe-message "/bin/sh" "-c" ${command}) ${retval}))
</code>
</option>
<option value="less-than">
- <title>is less than</title>
+ <title>returns less than</title>
<code>
- (match-all (&lt; (shell-exec ${command}) ${retval}))
+ (match-all (&lt; (pipe-message "/bin/sh" "-c" ${command}) ${retval}))
</code>
</option>
</input>
@@ -682,9 +682,9 @@
<code>(play-sound ${sound})</code>
<input type="file" name="sound"/>
</part>
- <part name="shell-exec">
- <title>Execute Shell Command</title>
- <code>(shell-exec ${command})</code>
+ <part name="shell">
+ <title>Shell Command</title>
+ <code>(shell "/bin/sh" "-c" ${command})</code>
<input type="command" name="command"/>
</part>
</actionset>
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");