Browse Source

Prevent user@host URLs from freezing processes

Jordi Boggiano 13 years ago
parent
commit
da5b084192
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/Packagist/WebBundle/Entity/Package.php

+ 11 - 1
src/Packagist/WebBundle/Entity/Package.php

@@ -94,6 +94,7 @@ class Package
     private $indexedAt;
     private $indexedAt;
 
 
     private $entityRepository;
     private $entityRepository;
+    private $repositoryClass;
 
 
     public function __construct()
     public function __construct()
     {
     {
@@ -129,7 +130,11 @@ class Package
 
 
         $repo = $this->repositoryClass;
         $repo = $this->repositoryClass;
         if (!$repo) {
         if (!$repo) {
-            $context->addViolation('No valid/supported repository was found at the given URL', array(), null);
+            if (preg_match('{//.+@}', $this->repository)) {
+                $context->addViolation('URLs with user@host are not supported, use a read-only public URL', array(), null);
+            } else {
+                $context->addViolation('No valid/supported repository was found at the given URL', array(), null);
+            }
             return;
             return;
         }
         }
         try {
         try {
@@ -264,6 +269,11 @@ class Package
     {
     {
         $this->repository = $repository;
         $this->repository = $repository;
 
 
+        // avoid user@host URLs
+        if (preg_match('{//.+@}', $repository)) {
+            return;
+        }
+
         $repositoryManager = new RepositoryManager;
         $repositoryManager = new RepositoryManager;
         $repositoryManager->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
         $repositoryManager->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
         $repositoryManager->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
         $repositoryManager->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');