[BUGFIX] language condition does not match exact string 20/30920/3
authorSusanne Moog <typo3@susannemoog.de>
Fri, 20 Jun 2014 11:58:35 +0000 (13:58 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 20 Jun 2014 15:06:51 +0000 (17:06 +0200)
The documentation for conditions of type "language" states: "The values
must be a straight match with the value of getenv('HTTP_ACCEPT_LANGUAGE')
from PHP." (or you can use wildcards). Exact matches are actually
not working - and the unit test showing the problem was skipped.

Patch adds the feature as documented and adjusts the unit test.

Change-Id: I5691fff41c889476d8149d6f92c26731ad7bb1fd
Resolves: #59707
Releases: 6.3
Reviewed-on: https://review.typo3.org/30920
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Classes/Configuration/TypoScript/ConditionMatching/AbstractConditionMatcher.php
typo3/sysext/frontend/Tests/Unit/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php

index 0fb0697..036cc5d 100644 (file)
@@ -292,6 +292,9 @@ abstract class AbstractConditionMatcher {
                                }
                                break;
                        case 'language':
+                               if (GeneralUtility::getIndpEnv('HTTP_ACCEPT_LANGUAGE') === $value) {
+                                       return TRUE;
+                               }
                                $values = GeneralUtility::trimExplode(',', $value, TRUE);
                                foreach ($values as $test) {
                                        if (preg_match('/^\\*.+\\*$/', $test)) {
index dc1e75b..2282727 100644 (file)
@@ -236,9 +236,8 @@ class ConditionMatcherTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function languageConditionMatchesCompleteLanguagesExpression() {
-               $this->markTestSkipped('This comparison seems to be incomplete in \TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher.');
                $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3';
-               $this->assertTrue($this->matchCondition->match('[language = de-de,de;q=0.8]'));
+               $this->assertTrue($this->matchCondition->match('[language = de-de,de;q=0.8,en-us;q=0.5,en;q=0.3]'));
        }
 
        /**