From b34be8190edbca1882b5abfcb823bb997dd40193 Mon Sep 17 00:00:00 2001 From: Mateusz Uzdowski Date: Mon, 16 Apr 2012 13:58:23 +1200 Subject: [PATCH] BUGFIX: normalise the config file, PCRE does not handle Windows/Mac linebreaks (os7133) --- core/manifest/ConfigManifest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/manifest/ConfigManifest.php b/core/manifest/ConfigManifest.php index 374a86f1c..2636a21d1 100644 --- a/core/manifest/ConfigManifest.php +++ b/core/manifest/ConfigManifest.php @@ -187,9 +187,12 @@ class SS_ConfigManifest { 'file' => basename(basename($basename, '.yml'), '.yaml') ); + // Make sure the linefeeds are all converted to \n, PCRE '$' will not match anything else. + $fileContents = str_replace(array("\r\n", "\r"), "\n", file_get_contents($pathname)); + // YAML parsers really should handle this properly themselves, but neither spyc nor symfony-yaml do. So we // follow in their vein and just do what we need, not what the spec says - $parts = preg_split('/^---$/m', file_get_contents($pathname), -1, PREG_SPLIT_NO_EMPTY); + $parts = preg_split('/^---$/m', $fileContents, -1, PREG_SPLIT_NO_EMPTY); // If only one document, it's a headerless fragment. So just add it with an anonymous name if (count($parts) == 1) {