Skip to content
This repository
Browse code

BUGFIX: normalise the config file, PCRE does not handle Windows/Mac l…

…inebreaks (os7133)
  • Loading branch information...
commit b34be8190edbca1882b5abfcb823bb997dd40193 1 parent e99ada4
Mateusz U authored April 16, 2012

Showing 1 changed file with 4 additions and 1 deletion. Show diff stats Hide diff stats

  1. 5  core/manifest/ConfigManifest.php
5  core/manifest/ConfigManifest.php
@@ -187,9 +187,12 @@ public function addYAMLConfigFile($basename, $pathname, $depth) {
187 187
 			'file' => basename(basename($basename, '.yml'), '.yaml')
188 188
 		);
189 189
 		
  190
+		// Make sure the linefeeds are all converted to \n, PCRE '$' will not match anything else.
  191
+		$fileContents = str_replace(array("\r\n", "\r"), "\n", file_get_contents($pathname));
  192
+
190 193
 		// YAML parsers really should handle this properly themselves, but neither spyc nor symfony-yaml do. So we
191 194
 		// follow in their vein and just do what we need, not what the spec says
192  
-		$parts = preg_split('/^---$/m', file_get_contents($pathname), -1, PREG_SPLIT_NO_EMPTY);
  195
+		$parts = preg_split('/^---$/m', $fileContents, -1, PREG_SPLIT_NO_EMPTY);
193 196
 
194 197
 		// If only one document, it's a headerless fragment. So just add it with an anonymous name
195 198
 		if (count($parts) == 1) {

0 notes on commit b34be81

Please sign in to comment.
Something went wrong with that request. Please try again.