From: Marcin Haba Date: Fri, 26 Feb 2016 08:03:13 +0000 (+0100) Subject: baculum: Tweak escape config file values X-Git-Tag: Release-7.4.1~27 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c409de5eb7ce5c288a9521169e5ec981aede811f;p=bacula%2Fbacula baculum: Tweak escape config file values --- diff --git a/gui/baculum/protected/Class/Miscellaneous.php b/gui/baculum/protected/Class/Miscellaneous.php index 957e85b998..c7b95ba792 100644 --- a/gui/baculum/protected/Class/Miscellaneous.php +++ b/gui/baculum/protected/Class/Miscellaneous.php @@ -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. *