Przeglądaj źródła

fixed ZF-9590
modified regex to detect ActiveDirectory datetime-format

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21937 44c647ce-9c0f-0410-b52a-842ac1e357ba

sgehrig 15 lat temu
rodzic
commit
65648b5e8f

+ 1 - 1
library/Zend/Ldap/Attribute.php

@@ -399,7 +399,7 @@ class Zend_Ldap_Attribute
     private static function _valueFromLdapDateTime($value)
     {
         $matches = array();
-        if (preg_match('/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})([+-]\d{4}|Z)$/', $value, $matches)) {
+        if (preg_match('/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(?:\.0)?([+-]\d{4}|Z)$/', $value, $matches)) {
             $year = $matches[1];
             $month = $matches[2];
             $day = $matches[3];

+ 7 - 0
tests/Zend/Ldap/AttributeTest.php

@@ -418,6 +418,13 @@ class Zend_Ldap_AttributeTest extends PHPUnit_Framework_TestCase
             Zend_Ldap_Attribute::convertFromLdapDateTimeValue($ldap));
     }
 
+    public function testConvertFromLdapDateTimeValueActiveDirectory()
+    {
+        $ldap='20080625123030.0+0200';
+        $this->assertEquals(gmmktime(10, 30, 30, 6, 25, 2008),
+            Zend_Ldap_Attribute::convertFromLdapDateTimeValue($ldap));
+    }
+
     public function testConvertToLdapDateTimeValue()
     {
         $ts=mktime(12, 30, 30, 6, 25, 2008);