From 53bbb49360598439f3cc2dd26532ed9e7b17ef7e Mon Sep 17 00:00:00 2001 From: Jaime Perez Crespo <jaime.perez@uninett.no> Date: Tue, 1 Sep 2015 14:03:09 +0200 Subject: [PATCH] SimpleSAML\Utils\Attributes::getExpectedAttribute(): Check if the attribute has any values, and raise an exception if not. --- lib/SimpleSAML/Utils/Attributes.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/SimpleSAML/Utils/Attributes.php b/lib/SimpleSAML/Utils/Attributes.php index d4b6d28d7..266084a7c 100644 --- a/lib/SimpleSAML/Utils/Attributes.php +++ b/lib/SimpleSAML/Utils/Attributes.php @@ -43,9 +43,13 @@ class Attributes $attribute = $attributes[$expected]; if (!is_array($attribute)) { - throw new \SimpleSAML_Error_Exception('The attributes array is not normalized, values should be arrays.'); + throw new \InvalidArgumentException('The attributes array is not normalized, values should be arrays.'); } - if (count($attribute) > 1) { + + if (count($attribute) === 0) { + throw new \SimpleSAML_Error_Exception("Empty attribute '".$expected."'.'"); + + } elseif (count($attribute) > 1) { if ($allow_multiple === false) { throw new \SimpleSAML_Error_Exception( 'More than one value found for the attribute, multiple values not allowed.' -- GitLab