Bug #23121
closed
Login to backend fails with IPv6 Address as HTTP_HOST
Added by Roland Schenke almost 14 years ago.
Updated over 5 years ago.
Description
When one is trying to log into the backend with an IPv6 Address like http://[::1]/typo3/ a RuntimeException is thrown in class.t3lib_userauth.php::checkAuthentication() because "this host address" mismatches the "referer host".
The error lies in t3lib_div::getIndpEnv().
In case of t3lib_div::getIndpEnv('TYPO3_HOST_ONLY') the HTTP_HOST is treated as IPv4 and therefore explode()ed at the colon(s). The first element of the resulting array is used as the TYPO3_HOST_ONLY value.
Because IPv6 Addresses can and have several colons I extended t3lib_div::getIndpEnv() at the appropriate places. This includes TYPO3_PORT.
Patch (hopefully working) and unit test included.
(issue imported from #M15034)
Files
class.t3lib_div.php.patch (1.28 KB)
class.t3lib_div.php.patch |
|
Administrator Admin, 2010-07-07 19:43
|
|
t3lib_divTest.php.patch (693 Bytes)
t3lib_divTest.php.patch |
|
Administrator Admin, 2010-07-07 19:43
|
|
15034v2.patch (2.09 KB)
15034v2.patch |
|
Administrator Admin, 2010-07-07 23:34
|
|
15034v2_UnitTest.patch (1.36 KB)
15034v2_UnitTest.patch |
|
Administrator Admin, 2010-07-07 23:34
|
|
15034v3.patch (2.27 KB)
15034v3.patch |
|
Administrator Admin, 2010-07-08 00:07
|
|
15034v3_UnitTest.patch (2.31 KB)
15034v3_UnitTest.patch |
|
Administrator Admin, 2010-07-08 00:07
|
|
15034v4_UnitTest.patch (1.73 KB)
15034v4_UnitTest.patch |
|
Administrator Admin, 2010-07-08 21:06
|
|
15034v5_UnitTest.patch (1.77 KB)
15034v5_UnitTest.patch |
|
Administrator Admin, 2010-07-09 02:11
|
|
15034_v4.diff (2.13 KB)
15034_v4.diff |
|
Administrator Admin, 2010-07-14 09:29
|
|
15034_v5.diff (1.27 KB)
15034_v5.diff |
|
Administrator Admin, 2010-07-15 07:37
|
|
15034_v6.diff (1.01 KB)
15034_v6.diff |
|
Administrator Admin, 2010-07-15 10:19
|
|
15034_v7.diff (1.02 KB)
15034_v7.diff |
|
Administrator Admin, 2010-07-16 07:43
|
|
15034v6_UnitTest.diff (1.93 KB)
15034v6_UnitTest.diff |
|
Administrator Admin, 2010-07-16 07:44
|
|
15034_09.diff (1.03 KB)
15034_09.diff |
|
Administrator Admin, 2010-12-30 20:03
|
|
15034_09-test.diff (1.66 KB)
15034_09-test.diff |
|
Administrator Admin, 2010-12-30 20:04
|
|
patch useless, forgot some essential code... sorry
sorry for the confusion, it's my very first bugfix to the core :-)
15034v3.patch should correctly recognize both IPv4 and IPv6 for TYPO3_HOST_ONLY and TYPO3_PORT
includes revised unit test in 15034v3_UnitTest.patch
Regarding the test:
Could you use 2 dataproviders instead a bunch of asserts?
@Nikolas Hagelstein thanks for pointing that out
uploaded 15034v5_UnitTest.patch using dataProvider
Thanks for your patch, Roland!
By reading I see the following CGL glitches:
- Space after "," as argument separator is sometimes missing
self::getIndpEnv('HTTP_HOST'),']:')
should be
self::getIndpEnv('HTTP_HOST'), ']:')
- Comments should be intended by one Tab
I'm unsure, how to handle according to CGL
}
// blabla
else {
Please remove the commented out lines:
+ //$p = explode(':',self::getIndpEnv('HTTP_HOST'));
+ //$retVal = $p0;
Updated patch attached.
Think you should send it to the Core list!
thanks Steffen Gebert!
posted to core list and tagged as "pending in core list"
15034_v5.diff contains a better aproach with less code
15034_v6.diff removed 2 CGL issues
big thanks to Caspar!
15034_v7.diff with the latest recommendations from the core list
and improved human readability for the unit test
- trunk rev. 9971
- 4.4 rev. 9972
- 4.3 rev. 9973
- Status changed from Resolved to Closed
Also available in: Atom
PDF