diff options
author | Peter Wu | 2014-07-20 23:58:53 +0200 |
---|---|---|
committer | Peter Wu | 2014-07-20 23:58:53 +0200 |
commit | 32489dfa569d0247a3175f0b6cf9641e2a6a66c1 (patch) | |
tree | af7b52c4206163a69d29a5443849889cd2f158e9 | |
parent | Display a HTTP error if the command failed (diff) | |
download | apt-panopticon_cgp-32489dfa569d0247a3175f0b6cf9641e2a6a66c1.zip apt-panopticon_cgp-32489dfa569d0247a3175f0b6cf9641e2a6a66c1.tar.gz apt-panopticon_cgp-32489dfa569d0247a3175f0b6cf9641e2a6a66c1.tar.bz2 apt-panopticon_cgp-32489dfa569d0247a3175f0b6cf9641e2a6a66c1.tar.xz |
Fix regex for strange datadirs
If a datadir would contain characters with a special meaning in regex
(e.g. `/tmp/logs (new)`), then the function would blow up.
-rw-r--r-- | type/Base.class.php | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/type/Base.class.php b/type/Base.class.php index c3741bd..e18d27a 100644 --- a/type/Base.class.php +++ b/type/Base.class.php | |||
@@ -165,6 +165,7 @@ class Type_Base { | |||
165 | $this->files = array(); | 165 | $this->files = array(); |
166 | $this->identifiers = array(); | 166 | $this->identifiers = array(); |
167 | 167 | ||
168 | $datadir_prefix = preg_quote($this->datadir, '#'); | ||
168 | foreach($files as $filename) { | 169 | foreach($files as $filename) { |
169 | $basename=basename($filename,'.rrd'); | 170 | $basename=basename($filename,'.rrd'); |
170 | $instance = strpos($basename,'-') | 171 | $instance = strpos($basename,'-') |
@@ -173,7 +174,9 @@ class Type_Base { | |||
173 | 174 | ||
174 | $this->tinstances[] = $instance; | 175 | $this->tinstances[] = $instance; |
175 | $this->files[$instance] = $filename; | 176 | $this->files[$instance] = $filename; |
176 | $this->identifiers[$instance] = preg_replace("#^$this->datadir/(.*)\.rrd$#", '$1', $filename); | 177 | $this->identifiers[$instance] = preg_replace( |
178 | "#^{$datadir_prefix}/(.*)\.rrd$#", '$1', | ||
179 | $filename); | ||
177 | } | 180 | } |
178 | 181 | ||
179 | sort($this->tinstances); | 182 | sort($this->tinstances); |