Normalize protocol of internal URLs
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 11 Mar 2014 13:58:31 +0000 (14:58 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 11 Mar 2014 14:00:28 +0000 (15:00 +0100)
wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php
wcfsetup/install/files/lib/util/StringUtil.class.php

index 5e3ba638ba5bcb42303cd05776b1c13d38c6c1a9..2b97324d11a2fe1673456a44be95d228d4d67c6b 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\system\application;
 use wcf\data\application\ApplicationAction;
 use wcf\data\application\ApplicationList;
 use wcf\system\cache\builder\ApplicationCacheBuilder;
+use wcf\system\Regex;
 use wcf\system\SingletonFactory;
 
 /**
@@ -144,14 +145,15 @@ class ApplicationHandler extends SingletonFactory {
         * @return      boolean
         */
        public function isInternalURL($url) {
+               $protocolRegex = new Regex('^https(?=://)');
                if (empty($this->pageURLs)) {
                        foreach ($this->getApplications() as $application) {
-                               $this->pageURLs[] = $application->getPageURL();
+                               $this->pageURLs[] = $protocolRegex->replace($application->getPageURL(), 'http');
                        }
                }
                
                foreach ($this->pageURLs as $pageURL) {
-                       if (stripos($url, $pageURL) === 0) {
+                       if (stripos($protocolRegex->replace($url, 'http'), $pageURL) === 0) {
                                return true;
                        }
                }
index bba035994dfbcf2c0da2e8a31ce9839d4594d16a..2b3727e1d290a58269deb950e0e7c8b0d3cb73e8 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\util;
 use wcf\system\application\ApplicationHandler;
+use wcf\system\request\RouteHandler;
 use wcf\system\WCF;
 
 /**
@@ -741,6 +742,7 @@ final class StringUtil {
                $external = true;
                if (ApplicationHandler::getInstance()->isInternalURL($url)) {
                        $external = false;
+                       $url = preg_replace('~^https?://~', RouteHandler::getProtocol(), $url);
                }
                
                // cut visible url