Skip to content

Commit

Permalink
Merge branch 'hotfix/7513' into develop
Browse files Browse the repository at this point in the history
Forward port zendframework#7513
  • Loading branch information
weierophinney committed May 11, 2015
2 parents 90e0b3e + 3dd91dc commit 7eb0eeb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion library/Zend/Ldap/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private static function valueFromLdap($value)
} else {
return $return;
}
} catch (Exception\InvalidArgumentException $e) {
} catch (Converter\Exception\InvalidArgumentException $e) {
return $value;
}
}
Expand Down
10 changes: 9 additions & 1 deletion library/Zend/Ldap/Converter/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,15 @@ public static function fromLdapDateTime($date, $asUtc = true)
. $time['offdir']
. str_pad($time['offsethours'], 2, '0', STR_PAD_LEFT)
. str_pad($time['offsetminutes'], 2, '0', STR_PAD_LEFT);
$date = new DateTime($timestring);
try {
$date = new DateTime($timestring);
} catch (\Exception $e) {
throw new Exception\InvalidArgumentException(
'Invalid date format found',
0,
$e
);
}
if ($asUtc) {
$date->setTimezone(new DateTimeZone('UTC'));
}
Expand Down
8 changes: 8 additions & 0 deletions tests/ZendTest/Ldap/AttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ public function testGetNonExistentAttributeValue()
$this->assertNull($value);
}

public function testInvalidValue()
{
$data = array('uid' => array('45678+'));
$value = Attribute::getAttribute($data, 'uid', 0);

$this->assertEquals('45678+', $value);
}

public function testGetNonExistentAttribute()
{
$data = array('uid' => array('value'));
Expand Down

0 comments on commit 7eb0eeb

Please sign in to comment.