Author: ornicar2
Date: 2010-02-10 23:50:03 +0100 (Wed, 10 Feb 2010)
New Revision: 27867

Modified:
   plugins/diemPlugin/trunk/dmCorePlugin/lib/log/dmFileLog.php
Log:
[Diem]
- fixed possible issue in dmFileLog if a message contains a \n

Modified: plugins/diemPlugin/trunk/dmCorePlugin/lib/log/dmFileLog.php
===================================================================
--- plugins/diemPlugin/trunk/dmCorePlugin/lib/log/dmFileLog.php 2010-02-10 
22:45:18 UTC (rev 27866)
+++ plugins/diemPlugin/trunk/dmCorePlugin/lib/log/dmFileLog.php 2010-02-10 
22:50:03 UTC (rev 27867)
@@ -6,7 +6,8 @@
   $dispatcher,
   $filesystem,
   $serviceContainer,
-  $options;
+  $options,
+  $nbFields;
   
   public function getDefaultOptions()
   {
@@ -34,6 +35,8 @@
     {
       $this->options['file'] = dmProject::rootify($this->options['file']);
     }
+
+    $this->nbFields = count($this->fields);
   }
   
   public function log(array $data)
@@ -125,7 +128,10 @@
           continue;
         }
         
-        $data = $this->restoreKeys($this->decode($encodedLine));
+        if(!($data = $this->restoreKeys($this->decode($encodedLine))))
+        {
+          continue;
+        }
         
         if ($filter && !call_user_func($filter, $data))
         {
@@ -181,7 +187,7 @@
   
   protected function encode(array $array)
   {
-    return implode('|', str_replace('|', ' ', $array));
+    return implode('|', str_replace(array('|', "\n"), ' ', $array));
   }
   
   protected function decode($string)
@@ -191,6 +197,11 @@
 
   protected function restoreKeys(array $arrayEntry)
   {
+    if($this->nbFields !== count($arrayEntry))
+    {
+      return false;
+    }
+
     return array_combine($this->fields, $arrayEntry);
   }
   

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to