CRM-18199 CRM_Utils_File::sourceSQLFile too greedy
authorGiovanni Gargani <giovanni@gargani.it>
Fri, 9 Sep 2016 22:36:09 +0000 (00:36 +0200)
committerggargani <giovanni@gargani.it>
Fri, 16 Sep 2016 05:57:51 +0000 (07:57 +0200)
Refactored the 2 comemnt stripping regexp in just one and fixed the
greedyness

CRM/Utils/File.php

index 485280bd74388dff1f7e43e6945ee069cb96606b..64528a3855456117236cd4c02e02b907708ce84a 100644 (file)
@@ -324,8 +324,7 @@ class CRM_Utils_File {
 
     // get rid of comments starting with # and --
 
-    $string = preg_replace("/^#[^\n]*$/m", "\n", $string);
-    $string = preg_replace("/^(--[^-]).*/m", "\n", $string);
+    $string = preg_replace("/^(#|--)[^\R]*$/m", "", $string);
 
     $queries = preg_split('/;\s*$/m', $string);
     foreach ($queries as $query) {