Browse Source

Make sure invalid authors are purged

Jordi Boggiano 12 years ago
parent
commit
5b9f190bcd
1 changed files with 8 additions and 0 deletions
  1. 8 0
      src/Composer/Package/Loader/ValidatingArrayLoader.php

+ 8 - 0
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']);