From 5b9f190bcde0c87a9bcde482af872acc883b1b13 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 8 Sep 2012 13:47:08 +0200 Subject: [PATCH] Make sure invalid authors are purged --- src/Composer/Package/Loader/ValidatingArrayLoader.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Composer/Package/Loader/ValidatingArrayLoader.php b/src/Composer/Package/Loader/ValidatingArrayLoader.php index 653ed4b42..d48d853fd 100644 --- a/src/Composer/Package/Loader/ValidatingArrayLoader.php +++ b/src/Composer/Package/Loader/ValidatingArrayLoader.php @@ -81,6 +81,11 @@ class ValidatingArrayLoader implements LoaderInterface $this->validateArray('authors'); if (!empty($this->config['authors'])) { foreach ($this->config['authors'] as $key => $author) { + if (!is_array($author)) { + $this->errors[] = 'authors.'.$key.' : should be an array, '.gettype($author).' given'; + unset($this->config['authors'][$key]); + continue; + } if (isset($author['homepage']) && !$this->filterUrl($author['homepage'])) { $this->errors[] = 'authors.'.$key.'.homepage : invalid value, must be a valid http/https URL'; unset($this->config['authors'][$key]['homepage']); @@ -97,6 +102,9 @@ class ValidatingArrayLoader implements LoaderInterface $this->errors[] = 'authors.'.$key.'.role : invalid value, must be a string'; unset($this->config['authors'][$key]['role']); } + if (empty($this->config['authors'][$key])) { + unset($this->config['authors'][$key]); + } } if (empty($this->config['authors'])) { unset($this->config['authors']);