Sfoglia il codice sorgente

[HttpFoundation] Cookie values should not be restricted

Jordi Boggiano 13 anni fa
parent
commit
e06cea9aaa

+ 0 - 4
src/Symfony/Component/HttpFoundation/Cookie.php

@@ -48,10 +48,6 @@ class Cookie
             throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name));
         }
 
-        if (preg_match("/[,; \t\r\n\013\014]/", $value)) {
-            throw new \InvalidArgumentException(sprintf('The cookie value "%s" contains invalid characters.', $value));
-        }
-
         if (empty($name)) {
             throw new \InvalidArgumentException('The cookie name cannot be empty.');
         }

+ 0 - 24
tests/Symfony/Tests/Component/HttpFoundation/CookieTest.php

@@ -36,20 +36,6 @@ class CookieTest extends \PHPUnit_Framework_TestCase
         );
     }
 
-    public function invalidValues()
-    {
-        return array(
-            array(",MyValue"),
-            array(";MyValue"),
-            array(" MyValue"),
-            array("\tMyValue"),
-            array("\rMyValue"),
-            array("\nMyValue"),
-            array("\013MyValue"),
-            array("\014MyValue"),
-        );
-    }
-
     /**
      * @dataProvider invalidNames
      * @expectedException InvalidArgumentException
@@ -60,16 +46,6 @@ class CookieTest extends \PHPUnit_Framework_TestCase
         new Cookie($name);
     }
 
-    /**
-     * @dataProvider invalidValues
-     * @expectedException InvalidArgumentException
-     * @covers Symfony\Component\HttpFoundation\Cookie::__construct
-     */
-    public function testInstantiationThrowsExceptionIfCookieValueContainsInvalidCharacters($value)
-    {
-        new Cookie('MyCookie', $value);
-    }
-
     /**
      * @expectedException InvalidArgumentException
      */