Browse Source

Prevent packages ending in .json to be added, refs #504

Jordi Boggiano 9 years ago
parent
commit
da81c13bd0
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/Packagist/WebBundle/Entity/Package.php

+ 5 - 0
src/Packagist/WebBundle/Entity/Package.php

@@ -244,6 +244,11 @@ class Package
                 return;
             }
 
+            if (preg_match('{\.json$}', $information['name'])) {
+                $context->addViolationAt($property, 'The package name '.$information['name'].' is invalid, package names can not end in .json, consider renaming it or perhaps using a -json suffix instead.', array(), null);
+                return;
+            }
+
             if (preg_match('{[A-Z]}', $information['name'])) {
                 $suggestName = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $information['name']);
                 $suggestName = strtolower($suggestName);