config: Escape and unescape line breaks in ini values

refs #3705
This commit is contained in:
Johannes Meyer 2019-03-04 12:16:06 +01:00
parent 403c2d3495
commit 769d490631
2 changed files with 10 additions and 8 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}