summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Wrobel <wrobel@pardus.de>2010-04-07 06:14:38 (GMT)
committerGunnar Wrobel <wrobel@pardus.de>2010-04-07 06:14:38 (GMT)
commit9ac9e725da4dc1238e8debfbdcf3b05ea4389de1 (patch)
treef170ca1dd64c30f212ca33ed3c879a86fe7b7069
parent3c12e82b2ce89fd89a14bd60544f0563e6cb63b4 (diff)
downloadkolab-webadmin-9ac9e725da4dc1238e8debfbdcf3b05ea4389de1.tar.gz
Full escaping of deactivated script segments.
-rw-r--r--lib/KolabAdmin/Sieve.php3
-rw-r--r--lib/KolabAdmin/Sieve/Segment.php11
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/KolabAdmin/Sieve.php b/lib/KolabAdmin/Sieve.php
index 2f66378..3dbb6c0 100644
--- a/lib/KolabAdmin/Sieve.php
+++ b/lib/KolabAdmin/Sieve.php
@@ -116,6 +116,9 @@ class KolabAdmin_Sieve
if (!empty($id[1])) {
$type = strtolower($id[1]);
$class = 'KolabAdmin_Sieve_Segment_' . ucfirst($type);
+ if (!isset($id[2])) {
+ $match = preg_replace('/^#/m', '', $match);
+ }
$segments[$type] = new $class($match);
if (isset($id[2]) && $id[2] == 'ENABLED') {
$segments[$type]->setActive();
diff --git a/lib/KolabAdmin/Sieve/Segment.php b/lib/KolabAdmin/Sieve/Segment.php
index ef4d0bb..f6efc1e 100644
--- a/lib/KolabAdmin/Sieve/Segment.php
+++ b/lib/KolabAdmin/Sieve/Segment.php
@@ -95,12 +95,21 @@ abstract class KolabAdmin_Sieve_Segment
public function generate()
{
+ $script = $this->_generateScript();
+ if (!$this->_active) {
+ $script = preg_replace('/^(.)/m', '#$1', $script);
+ }
return '### SEGMENT START ' . strtoupper($this->type) .' ' .
(($this->_active) ? 'ENABLED' : 'DISABLED') . "\r\n" .
- vsprintf($this->template, $this->getArguments()) .
+ $script .
'### SEGMENT END ' . strtoupper($this->type) . "\r\n";
}
+ private function _generateScript()
+ {
+ return vsprintf($this->template, $this->getArguments());
+ }
+
protected function dotstuff($str)
{
return str_replace("\n.", "\n..", $str);