Date pattern %d conversion is invalid.
--------------------------------------

                 Key: LOG4PHP-18
                 URL: https://issues.apache.org/jira/browse/LOG4PHP-18
             Project: Log4php
          Issue Type: Bug
         Environment: log4php r692607,
PHP 5.2.4-2ubuntu5.3 with Suhosin-Patch 0.9.6.2,
Ubuntu 8.04 
            Reporter: Yomei Komiya


Date pattern %d conversion includes fragile regular expression and arbitrary  
substitute of  ','.
So user definition pattern (%d{format}) is not converted well.

patch as follows.
---------------------------------------------------------------------------------
diff -urN log4php/helpers/LoggerPatternConverter.php 
log4php.new/helpers/LoggerPatternConverter.php
--- log4php/helpers/LoggerPatternConverter.php
+++ log4php.new/helpers/LoggerPatternConverter.php
@@ -289,7 +289,7 @@
     {
         $timeStamp = $event->getTimeStamp();
         $usecs = round(($timeStamp - (int)$timeStamp) * 1000);
-        $this->df = str_replace("\u", "u", ereg_replace("[^\\]u", 
sprintf(',%03d', $usecs), $this->df));
+        $this->df = preg_replace('/((?<!\\\\)(?:\\\\{2})*)u/', '${1}' . 
sprintf('%03d', $usecs), $this->df);
          
         return date($this->df, $event->getTimeStamp());

---------------------------------------------------------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to