[BUGFIX] Unit tests for tslib_content query arguments fail
authorOliver Hader <oliver@typo3.org>
Fri, 12 Aug 2011 10:30:19 +0000 (12:30 +0200)
committerOliver Hader <oliver@typo3.org>
Fri, 12 Aug 2011 16:31:52 +0000 (18:31 +0200)
Since security fixes in July 2011 introduced a better encoding of URL
arguments, checks in the unit tests have to be modified as well.

Change-Id: I4162b93ef30ea6539f4f5a858629697ceccea48d
Resolves: #28946
Releases: 4.6, 4.5, 4.4
Reviewed-on: http://review.typo3.org/4285
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
tests/typo3/sysext/cms/tslib/tslib_contentTest.php

index acf418c..741efb8 100644 (file)
@@ -232,7 +232,7 @@ class tslib_contentTest extends tx_phpunit_testcase {
                $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]';
                $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']);
 
-               $expectedResult = '&key2=value2&key3[key32][key322]=value322';
+               $expectedResult = $this->rawUrlEncodeSquareBracketsInUrl('&key2=value2&key3[key32][key322]=value322');
                $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration);
                $this->assertEquals($expectedResult, $actualResult);
        }
@@ -261,7 +261,7 @@ class tslib_contentTest extends tx_phpunit_testcase {
                $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]';
                $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']);
 
-               $expectedResult = '&key2=value2&key3[key32][key322]=value322';
+               $expectedResult = $this->rawUrlEncodeSquareBracketsInUrl('&key2=value2&key3[key32][key322]=value322');
                $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration);
                $this->assertEquals($expectedResult, $actualResult);
        }
@@ -325,7 +325,7 @@ class tslib_contentTest extends tx_phpunit_testcase {
                        ),
                );
 
-               $expectedResult = '&key2=value2Overruled&key3[key32][key322]=value322Overruled';
+               $expectedResult = $this->rawUrlEncodeSquareBracketsInUrl('&key2=value2Overruled&key3[key32][key322]=value322Overruled');
                $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments);
                $this->assertEquals($expectedResult, $actualResult);
        }
@@ -374,7 +374,7 @@ class tslib_contentTest extends tx_phpunit_testcase {
                        ),
                );
 
-               $expectedResult = '&key2=value2Overruled&key3[key32][key321]=value321Overruled&key3[key32][key323]=value323Overruled';
+               $expectedResult = $this->rawUrlEncodeSquareBracketsInUrl('&key2=value2Overruled&key3[key32][key321]=value321Overruled&key3[key32][key323]=value323Overruled');
                $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments, TRUE);
                $this->assertEquals($expectedResult, $actualResult);
 
@@ -383,6 +383,20 @@ class tslib_contentTest extends tx_phpunit_testcase {
                $this->assertEquals($expectedResult, $actualResult);
        }
 
+       /**
+        * Encodes square brackets in URL.
+        *
+        * @param string $string
+        * @return string
+        */
+       private function rawUrlEncodeSquareBracketsInUrl($string) {
+               return str_replace(
+                       array('[', ']'),
+                       array('%5B', '%5D'),
+                       $string
+               );
+       }
+
 
        //////////////////////////////
        // Tests concerning crop
@@ -790,4 +804,4 @@ class tslib_contentTest extends tx_phpunit_testcase {
                );
        }
 }
-?>
\ No newline at end of file
+?>