diff --git a/library/Icinga/File/Ini/Dom/Directive.php b/library/Icinga/File/Ini/Dom/Directive.php index cdf4108b8..4279a5f71 100644 --- a/library/Icinga/File/Ini/Dom/Directive.php +++ b/library/Icinga/File/Ini/Dom/Directive.php @@ -157,11 +157,10 @@ class Directive { $str = trim($str); $str = str_replace('\\', '\\\\', $str); - $str = str_replace('"', '\\"', $str); + $str = str_replace('"', '\"', $str); + $str = str_replace("\r", '\r', $str); + $str = str_replace("\n", '\n', $str); - // line breaks in the value should always match the current system EOL sequence - // to assure editable configuration files - $str = preg_replace("/(\r\n)|(\n)/", PHP_EOL, $str); return $str; } } diff --git a/library/Icinga/File/Ini/IniParser.php b/library/Icinga/File/Ini/IniParser.php index 5b3c24c32..b42c09ecb 100644 --- a/library/Icinga/File/Ini/IniParser.php +++ b/library/Icinga/File/Ini/IniParser.php @@ -284,8 +284,8 @@ class IniParser */ protected static function unescapeSectionName($str) { - $str = str_replace('\\"', '"', $str); - $str = str_replace('\\;', ';', $str); + $str = str_replace('\"', '"', $str); + $str = str_replace('\;', ';', $str); return str_replace('\\\\', '\\', $str); } @@ -299,8 +299,11 @@ class IniParser */ protected static function unescapeOptionValue($str) { - $str = str_replace('\\"', '"', $str); + $str = str_replace('\n', "\n", $str); + $str = str_replace('\r', "\r", $str); + $str = str_replace('\"', '"', $str); + $str = str_replace('\\\\', '\\', $str); - return str_replace('\\\\', '\\', $str); + return $str; } }