[BUGFIX] Function buildUrl does not handle port setting 21/19721/4
authorNicole Cordes <typo3@cordes.co>
Sun, 7 Apr 2013 09:04:04 +0000 (11:04 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 7 Apr 2013 09:44:15 +0000 (11:44 +0200)
The function buildUrl in the TYPO3\CMS\Core\Utility\HttpUtility class
does not handle any port setting. This has to be added after the host
setting separated by a colon.

Change-Id: Ie2b24dd076b8abc79ababbd19d6699d6a9fb47a3
Fixes: #47012
Releases: 6.1, 6.0, 4.7
Reviewed-on: https://review.typo3.org/19721
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Classes/Utility/HttpUtility.php
typo3/sysext/core/Tests/Unit/Utility/HttpUtilityTest.php

index b2052d3..66da0e5 100644 (file)
@@ -118,7 +118,14 @@ class HttpUtility {
         * @see http://www.php.net/parse_url
         */
        static public function buildUrl(array $urlParts) {
-               return (isset($urlParts['scheme']) ? $urlParts['scheme'] . '://' : '') . (isset($urlParts['user']) ? $urlParts['user'] . (isset($urlParts['pass']) ? ':' . $urlParts['pass'] : '') . '@' : '') . (isset($urlParts['host']) ? $urlParts['host'] : '') . (isset($urlParts['path']) ? $urlParts['path'] : '') . (isset($urlParts['query']) ? '?' . $urlParts['query'] : '') . (isset($urlParts['fragment']) ? '#' . $urlParts['fragment'] : '');
+               return (isset($urlParts['scheme']) ? $urlParts['scheme'] . '://' : '') .
+                       (isset($urlParts['user']) ? $urlParts['user'] .
+                       (isset($urlParts['pass']) ? ':' . $urlParts['pass'] : '') . '@' : '') .
+                       (isset($urlParts['host']) ? $urlParts['host'] : '') .
+                       (isset($urlParts['port']) ? ':' . $urlParts['port'] : '') .
+                       (isset($urlParts['path']) ? $urlParts['path'] : '') .
+                       (isset($urlParts['query']) ? '?' . $urlParts['query'] : '') .
+                       (isset($urlParts['fragment']) ? '#' . $urlParts['fragment'] : '');
        }
 
 }
index 60f9815..be7b5ad 100644 (file)
@@ -49,7 +49,7 @@ class HttpUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function isUrlBuiltCorrectlyDataProvider() {
                return array(
-                       'rebuild url withouth scheme' => array(
+                       'rebuild url without scheme' => array(
                                parse_url('typo3.org/path/index.php'),
                                'typo3.org/path/index.php'
                        ),
@@ -58,8 +58,8 @@ class HttpUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                'http://typo3.org/path/index.php'
                        ),
                        'rebuild url with all properties' => array(
-                               parse_url('http://editor:secret@typo3.org/path/index.php?query=data#fragment'),
-                               'http://editor:secret@typo3.org/path/index.php?query=data#fragment'
+                               parse_url('http://editor:secret@typo3.org:8080/path/index.php?query=data#fragment'),
+                               'http://editor:secret@typo3.org:8080/path/index.php?query=data#fragment'
                        ),
                        'url without username, but password' => array(
                                array(