]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Tweak escape config file values
authorMarcin Haba <marcin.haba@bacula.pl>
Fri, 26 Feb 2016 08:03:13 +0000 (09:03 +0100)
committerKern Sibbald <kern@sibbald.com>
Tue, 31 May 2016 06:20:17 +0000 (08:20 +0200)
gui/baculum/protected/Class/Miscellaneous.php

index 957e85b9983079cae7dbb982e1fae50a02d77c54..c7b95ba79272acba8b04a50a7e113d090007bdac 100644 (file)
@@ -171,10 +171,12 @@ class Miscellaneous extends TModule {
                        $tmp .= "[$section]\n";
                                foreach($values as $key => $val){
                                        if(is_array($val)){
-                                               foreach($val as $k =>$v){
+                                               foreach($val as $k => $v) {
+                                                       $v = $this->escapeINIVal($v);
                                                        $tmp .= "{$key}[$k] = \"$v\"\n";
                                                }
                                        } else {
+                                               $val = $this->escapeINIVal($val);
                                                $tmp .= "$key = \"$val\"\n";
                                        }
                                }
@@ -187,6 +189,18 @@ class Miscellaneous extends TModule {
                return $result;
        }
 
+       /**
+        * Escape text written to INI-style file.
+        *
+        * @access private
+        * @param string $value text to escape
+        * @return string escaped text
+        */
+       private function escapeINIVal($value) {
+               $esc_value = str_replace('"', '\"', $value);
+               return $esc_value;
+       }
+
        /**
         * Parse INI-style configuration file.
         *