Remove linebreaks from configuration keys and values

This commit is contained in:
Matthias Jentsch 2014-11-11 15:07:42 +01:00
parent fdfad34e5c
commit c70f738236
1 changed files with 10 additions and 5 deletions

View File

@ -433,6 +433,9 @@ class IniEditor
*/ */
private function formatKey(array $key) private function formatKey(array $key)
{ {
foreach ($key as $i => $separator) {
$key[$i] = $this->sanitize($separator);
}
return implode($this->nestSeparator, $key); return implode($this->nestSeparator, $key);
} }
@ -599,7 +602,7 @@ class IniEditor
} }
/** /**
* Prepare a value for INe * Prepare a value for INI
* *
* @param $value The value of the string * @param $value The value of the string
* *
@ -613,10 +616,12 @@ class IniEditor
return $value; return $value;
} elseif (is_bool($value)) { } elseif (is_bool($value)) {
return ($value ? 'true' : 'false'); return ($value ? 'true' : 'false');
} elseif (strpos($value, '"') === false) {
return '"' . $value . '"';
} else {
return '"' . str_replace('"', '\"', $value) . '"';
} }
return '"' . str_replace('"', '\"', $this->sanitize($value)) . '"';
}
private function sanitize($value)
{
return str_replace('\n', '', $value);
} }
} }