Selaa lähdekoodia

improve arguments validation with redirections methods

Olivier Massot 4 vuotta sitten
vanhempi
commit
be83889b50
1 muutettua tiedostoa jossa 7 lisäystä ja 0 poistoa
  1. 7 0
      ot_admin/Classes/Controller/SiteController.php

+ 7 - 0
ot_admin/Classes/Controller/SiteController.php

@@ -661,6 +661,9 @@ class SiteController extends ActionController
 
         // Prepare the redirection
         if ($redirectTo) {
+            if ($redirectTo == $organizationId) {
+                throw new \InvalidArgumentException('redirectTo value has to be different from the organizationId');
+            }
             $originUrl = $this->getSiteInfosAction($organizationId)['baseUrl'];
             $targetUrl = $this->getSiteInfosAction($redirectTo)['baseUrl'];
         }
@@ -1230,6 +1233,10 @@ class SiteController extends ActionController
         $originUrl = $infos['baseUrl'];
         $rootUid = $infos['rootUid'];
 
+        if (preg_replace('/https?:\/\//', '', $originUrl) == preg_replace('/https?:\/\//', '', $newDomain) ) {
+            throw new \RuntimeException('The new domain should be different of the current one');
+        }
+
         $this->writeConfigFile($organizationId, $rootUid, $newDomain);
 
         if ($redirect) {