summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-31 15:21:04 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-31 15:21:04 -0400
commit36419d85aa849007998a4b69ac779de015a4e5ce (patch)
treeeb4b296cf38f2c3b0cdb889bfb988ec036b54617
parent1a4cc31d67cf7679966d6cf2928b7ad3e152c061 (diff)
downloadaerc-36419d85aa849007998a4b69ac779de015a4e5ce.zip
Use shell to execute filters, fix non-determinism
-rw-r--r--config/config.go3
-rw-r--r--widgets/msgviewer.go9
2 files changed, 5 insertions, 7 deletions
diff --git a/config/config.go b/config/config.go
index 7c80d20..a63b7e8 100644
--- a/config/config.go
+++ b/config/config.go
@@ -158,7 +158,8 @@ func LoadConfig(root *string) (*AercConfig, error) {
}
if filters, err := file.GetSection("filters"); err == nil {
// TODO: Parse the filter more finely, e.g. parse the regex
- for match, cmd := range filters.KeysHash() {
+ for _, match := range filters.KeyStrings() {
+ cmd := filters.KeysHash()[match]
filter := FilterConfig{
Command: cmd,
Filter: match,
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 56c3897..7d929e6 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -107,16 +107,13 @@ func NewMessageViewer(conf *config.AercConfig, store *lib.MessageStore,
}
pager = exec.Command(cmd[0], cmd[1:]...)
+ fmt.Printf("%v\n", conf.Filters)
for _, f := range conf.Filters {
- cmd, err = shlex.Split(f.Command)
- if err != nil {
- goto handle_error
- }
mime := msg.BodyStructure.MIMEType + "/" + msg.BodyStructure.MIMESubType
switch f.FilterType {
case config.FILTER_MIMETYPE:
if fnmatch.Match(f.Filter, mime, 0) {
- filter = exec.Command(cmd[0], cmd[1:]...)
+ filter = exec.Command("sh", "-c", f.Command)
}
case config.FILTER_HEADER:
var header string
@@ -131,7 +128,7 @@ func NewMessageViewer(conf *config.AercConfig, store *lib.MessageStore,
header = formatAddresses(msg.Envelope.Cc)
}
if f.Regex.Match([]byte(header)) {
- filter = exec.Command(cmd[0], cmd[1:]...)
+ filter = exec.Command("sh", "-c", f.Command)
}
}
if filter != nil {