Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/7513'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed May 11, 2015
2 parents 5784132 + 07a9158 commit 07bfa76
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/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 src/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 test/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 07bfa76

Please sign in to comment.