[BUGFIX] felogin: Use correct regex in redirect evaluation 00/39600/4
authorMarkus Klein <markus.klein@typo3.org>
Mon, 18 May 2015 17:28:00 +0000 (19:28 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Mon, 18 May 2015 18:16:11 +0000 (20:16 +0200)
Resolves: #67013
Releases: master, 6.2
Change-Id: Ifaf0a3125ac6b5c0f9e13c2f5c3d4db94aa43ea9
Reviewed-on: http://review.typo3.org/39600
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stephan GroƟberndt <stephan@grossberndt.de>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/felogin/Classes/Controller/FrontendLoginController.php
typo3/sysext/felogin/Tests/Unit/Controller/FrontendLoginControllerTest.php

index 589fd58..b60cd07 100644 (file)
@@ -627,7 +627,7 @@ class FrontendLoginController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
        /**
         * Process redirect methods. The function searches for a redirect url using all configured methods.
         *
-        * @return string Redirect url
+        * @return array Redirect URLs
         */
        protected function processRedirect() {
                $redirect_url = array();
@@ -689,7 +689,7 @@ class FrontendLoginController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
                                                                        $redirect_domain = $match[1];
                                                                        $found = FALSE;
                                                                        foreach (GeneralUtility::trimExplode(',', $this->conf['domains'], TRUE) as $d) {
-                                                                               if (preg_match('/(^|\\.)/' . $d . '$', $redirect_domain)) {
+                                                                               if (preg_match('/(?:^|\\.)' . $d . '$/', $redirect_domain)) {
                                                                                        $found = TRUE;
                                                                                        break;
                                                                                }
index b03322c..9f162f6 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Felogin\Tests\Unit\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
+
 /**
  * Test case
  *
@@ -449,4 +451,22 @@ class FrontendLoginControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->assertFalse($this->accessibleFixture->_call('isInCurrentDomain', $url));
        }
 
+       /**
+        * @test
+        */
+       public function processRedirectReferrerDomainsMatchesDomains() {
+               $conf = array(
+                       'redirectMode' => 'refererDomains',
+                       'domains' => 'example.com'
+               );
+
+               $this->accessibleFixture->_set('conf', $conf);
+               $this->accessibleFixture->_set('logintype', 'login');
+               $this->accessibleFixture->_set('referer', 'http://www.example.com/snafu');
+               /** @var TypoScriptFrontendController $tsfe */
+               $tsfe = $this->accessibleFixture->_get('frontendController');
+               $tsfe->loginUser = TRUE;
+               $this->assertSame(array('http://www.example.com/snafu'), $this->accessibleFixture->_call('processRedirect'));
+       }
+
 }