48 $this->testTableName =
'sys_domain';
49 $this->testHostName =
'hostname.tld';
50 $this->testSitePath =
'/';
51 $this->accessibleFixture = $this->
getAccessibleMock(
'TYPO3\\CMS\\Felogin\\Controller\\FrontendLoginController', array(
'dummy'));
52 $this->accessibleFixture->cObj = $this->getMock(
'TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
53 $GLOBALS[
'TSFE'] = $this->getMock(
'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array(), array(),
'', FALSE);
61 $_SERVER[
'ORIG_PATH_INFO'] = $_SERVER[
'PATH_INFO'] = $_SERVER[
'ORIG_SCRIPT_NAME'] = $_SERVER[
'SCRIPT_NAME'] = $this->testSitePath . TYPO3_mainDir;
69 $GLOBALS[
'TYPO3_DB'] = $this->getMock(
'TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array(
'exec_SELECTgetRows'));
71 ->expects($this->any())
72 ->method(
'exec_SELECTgetRows')
73 ->will($this->returnCallback(array($this,
'getDomainRecordsCallback')));
87 if ($table !== $this->testTableName) {
91 array(
'domainName' =>
'domainhostname.tld'),
92 array(
'domainName' =>
'otherhostname.tld/path'),
93 array(
'domainName' =>
'sub.domainhostname.tld/path/')
101 $this->assertEquals(\
TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv(
'TYPO3_SITE_PATH'), $this->testSitePath);
108 $this->assertEquals(\
TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv(
'TYPO3_SITE_URL'), (
'http://' . $this->testHostName) . $this->testSitePath);
115 $this->testHostName =
'somenewhostname.com';
116 $this->testSitePath =
'/somenewpath/';
118 $this->assertEquals(\
TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv(
'TYPO3_SITE_PATH'), $this->testSitePath);
125 $this->testHostName =
'somenewhostname.com';
126 $this->testSitePath =
'/somenewpath/';
128 $this->assertEquals(\
TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv(
'TYPO3_SITE_URL'), (
'http://' . $this->testHostName) . $this->testSitePath);
138 'absolute URL, hostname not in sys_domain, trailing slash' => array(
'http://badhost.tld/'),
139 'absolute URL, hostname not in sys_domain, no trailing slash' => array(
'http://badhost.tld'),
140 'absolute URL, subdomain in sys_domain, but main domain not, trailing slash' => array(
'http://domainhostname.tld.badhost.tld/'),
141 'absolute URL, subdomain in sys_domain, but main domain not, no trailing slash' => array(
'http://domainhostname.tld.badhost.tld'),
142 'non http absolute URL 1' => array(
'its://domainhostname.tld/itunes/'),
143 'non http absolute URL 2' => array(
'ftp://domainhostname.tld/download/'),
144 'XSS attempt 1' => array(
'javascript:alert(123)'),
145 'XSS attempt 2' => array(
'" onmouseover="alert(123)"'),
146 'invalid URL, HTML break out attempt' => array(
'" >blabuubb'),
147 'invalid URL, UNC path' => array(
'\\\\foo\\bar\\'),
148 'invalid URL, backslashes in path' => array(
'http://domainhostname.tld\\bla\\blupp'),
149 'invalid URL, linefeed in path' => array(
'http://domainhostname.tld/bla/blupp' . LF),
150 'invalid URL, only one slash after scheme' => array(
'http:/domainhostname.tld/bla/blupp'),
151 'invalid URL, illegal chars' => array(
'http://(<>domainhostname).tld/bla/blupp'),
162 $this->assertEquals(
'', $this->accessibleFixture->_call(
'validateRedirectUrl', $url));
172 'sane absolute URL' => array(
'http://domainhostname.tld/'),
173 'sane absolute URL with script' => array(
'http://domainhostname.tld/index.php?id=1'),
174 'sane absolute URL with realurl' => array(
'http://domainhostname.tld/foo/bar/foo.html'),
175 'sane absolute URL with homedir' => array(
'http://domainhostname.tld/~user/'),
176 'sane absolute URL with some strange chars encoded' => array(
'http://domainhostname.tld/~user/a%cc%88o%cc%88%c3%9fa%cc%82/foo.html'),
177 'sane absolute URL (domain record with path)' => array(
'http://otherhostname.tld/path/'),
178 'sane absolute URL with script (domain record with path)' => array(
'http://otherhostname.tld/path/index.php?id=1'),
179 'sane absolute URL with realurl (domain record with path)' => array(
'http://otherhostname.tld/path/foo/bar/foo.html'),
180 'sane absolute URL (domain record with path and slash)' => array(
'http://sub.domainhostname.tld/path/'),
181 'sane absolute URL with script (domain record with path slash)' => array(
'http://sub.domainhostname.tld/path/index.php?id=1'),
182 'sane absolute URL with realurl (domain record with path slash)' => array(
'http://sub.domainhostname.tld/path/foo/bar/foo.html'),
183 'relative URL, no leading slash 1' => array(
'index.php?id=1'),
184 'relative URL, no leading slash 2' => array(
'foo/bar/index.php?id=2'),
185 'relative URL, leading slash, no realurl' => array(
'/index.php?id=1'),
186 'relative URL, leading slash, realurl' => array(
'/de/service/imprint.html'),
197 $this->assertEquals($url, $this->accessibleFixture->_call(
'validateRedirectUrl', $url));
207 'absolute URL, missing subdirectory' => array(
'http://hostname.tld/'),
208 'absolute URL, wrong subdirectory' => array(
'http://hostname.tld/hacker/index.php'),
209 'absolute URL, correct subdirectory, no trailing slash' => array(
'http://hostname.tld/subdir'),
210 'absolute URL, correct subdirectory of sys_domain record, no trailing slash' => array(
'http://otherhostname.tld/path'),
211 'absolute URL, correct subdirectory of sys_domain record, no trailing slash, subdomain' => array(
'http://sub.domainhostname.tld/path'),
212 'relative URL, leading slash, no path' => array(
'/index.php?id=1'),
213 'relative URL, leading slash, wrong path' => array(
'/de/sub/site.html'),
214 'relative URL, leading slash, slash only' => array(
'/'),
224 $this->testSitePath =
'/subdir/';
227 $this->assertEquals(
'', $this->accessibleFixture->_call(
'validateRedirectUrl', $url));
237 'absolute URL, correct subdirectory' => array(
'http://hostname.tld/subdir/'),
238 'absolute URL, correct subdirectory, realurl' => array(
'http://hostname.tld/subdir/de/imprint.html'),
239 'absolute URL, correct subdirectory, no realurl' => array(
'http://hostname.tld/subdir/index.php?id=10'),
240 'absolute URL, correct subdirectory of sys_domain record' => array(
'http://otherhostname.tld/path/'),
241 'absolute URL, correct subdirectory of sys_domain record, subdomain' => array(
'http://sub.domainhostname.tld/path/'),
242 'relative URL, no leading slash, realurl' => array(
'de/service/imprint.html'),
243 'relative URL, no leading slash, no realurl' => array(
'index.php?id=1'),
244 'relative nested URL, no leading slash, no realurl' => array(
'foo/bar/index.php?id=2')
254 $this->testSitePath =
'/subdir/';
257 $this->assertEquals($url, $this->accessibleFixture->_call(
'validateRedirectUrl', $url));
270 'special get var id is not preserved' => array(
277 'simple additional parameter is not preserved if not specified in preservedGETvars' => array(
285 'all params except ignored ones are preserved if preservedGETvars is set to "all"' => array(
292 'tx_felogin_pi1' => array(
297 '&special1=23&special2[foo]=bar',
299 'preserve single parameter' => array(
306 'preserve whole parameter array' => array(
309 'tx_someext' => array(
317 '&L=3&tx_someext[foo]=simple&tx_someext[bar][baz]=simple',
319 'preserve part of sub array' => array(
322 'tx_someext' => array(
330 '&L=3&tx_someext[bar][baz]=simple',
332 'preserve keys on different levels' => array(
335 'no-preserve' =>
'whatever',
346 'L,tx_ext2,tx_ext3[bar]',
347 '&L=3&tx_ext2[foo]=simple&tx_ext3[bar][baz]=simple',
349 'preserved value that does not exist in get' => array(
354 'url params are encoded' => array(
355 array(
'tx_ext1' =>
'param with spaces and \\ %<>& /'),
357 '&tx_ext1=param%20with%20spaces%20and%20%20%25%3C%3E%26%20%2F' 372 $this->accessibleFixture->conf[
'preserveGETvars'] = $preserveVars;
373 $this->assertSame($expected, $this->accessibleFixture->_call(
'getPreserveGetVars'));
388 'url https, current host http' => array(
391 'https://example.com/foo.html' 393 'url http, current host https' => array(
396 'http://example.com/foo.html' 398 'url https, current host https' => array(
401 'https://example.com/foo.html' 403 'url http, current host http' => array(
406 'http://example.com/foo.html' 419 $_SERVER[
'HTTP_HOST'] =
$host;
420 $_SERVER[
'HTTPS'] = $https;
421 $this->assertTrue($this->accessibleFixture->_call(
'isInCurrentDomain', $url));
429 'simple difference' => array(
431 'http://typo3.org/foo.html' 433 'subdomain different' => array(
435 'http://foo.example.com/bar.html' 447 $_SERVER[
'HTTP_HOST'] =
$host;
448 $this->assertFalse($this->accessibleFixture->_call(
'isInCurrentDomain', $url));
456 'redirectMode' =>
'refererDomains',
457 'domains' =>
'example.com' 460 $this->accessibleFixture->_set(
'conf', $conf);
461 $this->accessibleFixture->_set(
'logintype',
'login');
462 $this->accessibleFixture->_set(
'referer',
'http://www.example.com/snafu');
464 $this->assertSame(array(
'http://www.example.com/snafu'), $this->accessibleFixture->_call(
'processRedirect'));
typo3SiteUrlEqualsStubSiteUrlAfterChangingInTest()
getPreserveGetVarsReturnsCorrectResult(array $getArray, $preserveVars, $expected)
validateRedirectUrlClearsUrlDataProvider()
typo3SitePathEqualsStubSitePathAfterChangingInTest()
validateRedirectUrlClearsInvalidUrlInSubdirectory($url)
validateRedirectUrlKeepsCleanUrlDataProvider()
isInCurrentDomainReturnsFalseIfDomainsAreDifferentDataProvider()
setUpFakeSitePathAndHost()
validateRedirectUrlKeepsCleanUrlInSubdirectory($url)
typo3SitePathEqualsStubSitePath()
validateRedirectUrlClearsInvalidUrlInSubdirectoryDataProvider()
validateRedirectUrlClearsUrl($url)
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
isInCurrentDomainReturnsFalseIfDomainsAreDifferent($host, $url)
getDomainRecordsCallback($fields, $table, $where)
validateRedirectUrlKeepsCleanUrlInSubdirectoryDataProvider()
processRedirectReferrerDomainsMatchesDomains()
validateRedirectUrlKeepsCleanUrl($url)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
isInCurrentDomainIgnoresSchemeDataProvider()
isInCurrentDomainIgnoresScheme($host, $https, $url)
getPreserveGetVarsReturnsCorrectResultDataProvider()
typo3SiteUrlEqualsStubSiteUrl()