Fixed handling of non-standard ports for cookie domain
authorAlexander Ebert <ebert@woltlab.com>
Fri, 24 Jan 2014 16:52:57 +0000 (17:52 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 24 Jan 2014 16:52:57 +0000 (17:52 +0100)
wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php
wcfsetup/install/files/lib/data/application/ApplicationAction.class.php

index af64d3fa98249a5cbe514c70a7d066938a79452c..edb78758ec0f45f1987262112bcf195aae774b36 100644 (file)
@@ -129,8 +129,12 @@ class ApplicationEditForm extends AbstractForm {
                                throw new UserInputException('cookieDomain', 'containsPath');
                        }
                        
+                       // strip port from cookie domain
+                       $regex = new Regex(':[0-9]+$');
+                       $this->cookieDomain = $regex->replace($this->cookieDomain, '');
+                       
                        // check if cookie domain shares the same domain (may exclude subdomains)
-                       if (!StringUtil::endsWith($this->domainName, $this->cookieDomain)) {
+                       if (!StringUtil::endsWith($regex->replace($this->domainName, ''), $this->cookieDomain)) {
                                throw new UserInputException('cookieDomain', 'notValid');
                        }
                }
index a6f6ab0ad62bc4fcdb9b9c4942f73bf717af196b..c64f2232c078d5485aca335dcb9e3e85598ced09 100644 (file)
@@ -5,6 +5,7 @@ use wcf\system\cache\builder\ApplicationCacheBuilder;
 use wcf\system\exception\PermissionDeniedException;
 use wcf\system\exception\UserInputException;
 use wcf\system\language\LanguageFactory;
+use wcf\system\Regex;
 use wcf\system\WCF;
 use wcf\util\FileUtil;
 use wcf\util\StringUtil;
@@ -52,9 +53,10 @@ class ApplicationAction extends AbstractDatabaseObjectAction {
                
                // calculate cookie path
                $domains = array();
+               $regex = new Regex(':[0-9]+');
                foreach ($this->objects as $application) {
                        $domainName = $application->domainName;
-                       if (StringUtil::endsWith($domainName, $application->cookieDomain)) {
+                       if (StringUtil::endsWith($regex->replace($domainName, ''), $application->cookieDomain)) {
                                $domainName = $application->cookieDomain;
                        }