mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-01-25 21:42:54 -05:00
LegacyConfigParser: Trim line in parseHeaderLine
To avoid whitespace and \r in header. Also supports DOS line endings. fixes #136
This commit is contained in:
parent
651bb15041
commit
5dfe4782ea
1 changed files with 3 additions and 4 deletions
|
|
@ -73,7 +73,7 @@ class LegacyConfigParser
|
|||
static::readMetadataFromString($name, $string)
|
||||
);
|
||||
|
||||
foreach (preg_split('/\n/', $string) as $line) {
|
||||
foreach (preg_split('/\r?\n/', $string) as $line) {
|
||||
$parser->parseLine($line);
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ class LegacyConfigParser
|
|||
|
||||
protected function readHeaderString($string, Metadata $metadata)
|
||||
{
|
||||
foreach (preg_split('/\n/', $string) as $line) {
|
||||
foreach (preg_split('/\r?\n/', $string) as $line) {
|
||||
$this->parseHeaderLine($line, $metadata);
|
||||
}
|
||||
|
||||
|
|
@ -168,8 +168,7 @@ class LegacyConfigParser
|
|||
*/
|
||||
protected static function parseHeaderLine($line, Metadata $metadata)
|
||||
{
|
||||
$line = trim($line);
|
||||
if (preg_match('/^\s*#\s+(.+?)\s*:\s*(.+)$/', $line, $m)) {
|
||||
if (preg_match('/^\s*#\s+(.+?)\s*:\s*(.+)$/', trim($line), $m)) {
|
||||
if ($metadata->hasKey($m[1])) {
|
||||
$metadata->set($m[1], $m[2]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue