Skip to content

Commit 9851f94

Browse files
committed
Fixed: FS#806 - Mailfilter & Folders names w/ spaces
1 parent 99d5dc8 commit 9851f94

File tree

1 file changed

+49
-39
lines changed

1 file changed

+49
-39
lines changed

interface/web/mail/mail_user_filter_edit.php

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -113,49 +113,59 @@ function getRule() {
113113

114114
$content = '';
115115
$content .= '### BEGIN FILTER_ID:'.$this->id."\n";
116-
117-
if($this->dataRecord["active"] == 'y') {
118-
119-
if($this->dataRecord["action"] == 'move') {
120-
116+
117+
$TargetNoQuotes = $this->dataRecord["target"];
118+
$TargetQuotes = "\"$TargetNoQuotes\"";
119+
120+
$TestChDirNoQuotes = '$DEFAULT/.'.$TargetNoQuotes;
121+
$TestChDirQuotes = "\"$TestChDirNoQuotes\"";
122+
123+
$MailDirMakeNoQuotes = $TargetQuotes.' $DEFAULT';
124+
125+
$EchoTargetFinal = $TargetNoQuotes;
126+
127+
128+
if($this->dataRecord["action"] == 'move') {
129+
121130
$content .= "
122-
`test -e ".'$DEFAULT/.'.$this->dataRecord["target"]."`
123-
if ( ".'$RETURNCODE'." != 0 )
131+
`test -e ".$TestChDirQuotes." && exit 1 || exit 0`
132+
if ( ".'$RETURNCODE'." != 1 )
124133
{
125-
`maildirmake -f ".$this->dataRecord["target"].' $DEFAULT'."`
126-
`chmod -R 0700 ".'$DEFAULT/'.$this->dataRecord["target"]."`
127-
`echo INBOX.".$this->dataRecord["target"]." >> ".'$DEFAULT'."/courierimapsubscribed`
134+
`maildirmake -f $MailDirMakeNoQuotes`
135+
`chmod -R 0700 ".$TestChDirQuotes."`
136+
`echo \"INBOX.$EchoTargetFinal\" >> ".'$DEFAULT'."/courierimapsubscribed`
128137
}
129-
";
130-
}
131-
132-
$content .= "if (/^".$this->dataRecord["source"].":";
133-
134-
$searchterm = preg_quote($this->dataRecord["searchterm"]);
135-
136-
if($this->dataRecord["op"] == 'contains') {
137-
$content .= ".*".$searchterm."/:h)\n";
138-
} elseif ($this->dataRecord["op"] == 'is') {
139-
$content .= $searchterm."$/:h)\n";
140-
} elseif ($this->dataRecord["op"] == 'begins') {
141-
$content .= $searchterm."/:h)\n";
142-
} elseif ($this->dataRecord["op"] == 'ends') {
143-
$content .= ".*".$searchterm."$/:h)\n";
144-
}
145-
146-
$content .= "{\n";
147-
$content .= "exception {\n";
148-
149-
if($this->dataRecord["action"] == 'move') {
150-
$content .= 'to $DEFAULT/.'.$this->dataRecord["target"]."/\n";
151-
} else {
152-
$content .= "to /dev/null\n";
153-
}
154-
155-
$content .= "}\n";
156-
$content .= "}\n";
157-
138+
";
139+
}
140+
141+
$content .= "if (/^".$this->dataRecord["source"].":";
142+
143+
$searchterm = preg_quote($this->dataRecord["searchterm"]);
144+
145+
if($this->dataRecord["op"] == 'contains') {
146+
$content .= ".*".$searchterm."/:h)\n";
147+
} elseif ($this->dataRecord["op"] == 'is') {
148+
$content .= $searchterm."$/:h)\n";
149+
} elseif ($this->dataRecord["op"] == 'begins') {
150+
$content .= $searchterm."/:h)\n";
151+
} elseif ($this->dataRecord["op"] == 'ends') {
152+
$content .= ".*".$searchterm."$/:h)\n";
158153
}
154+
155+
$content .= "{\n";
156+
$content .= "exception {\n";
157+
158+
if($this->dataRecord["action"] == 'move') {
159+
$content .= 'ID' . "$this->id" . 'EndFolder = "$DEFAULT/.' . $this->dataRecord['target'] . '/"' . "\n";
160+
$content .= "to ". '$ID' . "$this->id" . 'EndFolder' . "\n";
161+
} else {
162+
$content .= "to /dev/null\n";
163+
}
164+
165+
$content .= "}\n";
166+
$content .= "}\n";
167+
168+
//}
159169

160170
$content .= '### END FILTER_ID:'.$this->id."\n";
161171

0 commit comments

Comments
 (0)