summaryrefslogtreecommitdiff
path: root/vendor/symfony/http-foundation
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-10-10 00:28:20 +0100
committerGreg Roach <fisharebest@webtrees.net>2019-10-10 00:28:20 +0100
commit1413eee0f149cccf7c528e3673d7569a368e4a9b (patch)
tree0f7c151dcd9d1bbc1694e9d0aade1cdae5cc54e2 /vendor/symfony/http-foundation
parent3ecf8b4e3b9edb7773bcf328f4533da4f452929a (diff)
downloadwebtrees-1413eee0f149cccf7c528e3673d7569a368e4a9b.tar.gz
webtrees-1413eee0f149cccf7c528e3673d7569a368e4a9b.tar.bz2
webtrees-1413eee0f149cccf7c528e3673d7569a368e4a9b.zip
Update vendor dependencies
Diffstat (limited to 'vendor/symfony/http-foundation')
-rw-r--r--vendor/symfony/http-foundation/Cookie.php21
-rw-r--r--vendor/symfony/http-foundation/HeaderBag.php10
-rw-r--r--vendor/symfony/http-foundation/Response.php2
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/Handler/RedisSessionHandler.php8
-rw-r--r--vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php2
-rw-r--r--vendor/symfony/http-foundation/Tests/CookieTest.php23
-rw-r--r--vendor/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_urlencode.expected3
-rw-r--r--vendor/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_urlencode.php9
-rw-r--r--vendor/symfony/http-foundation/Tests/Fixtures/response-functional/invalid_cookie_name.php2
-rw-r--r--vendor/symfony/http-foundation/Tests/HeaderBagTest.php10
-rw-r--r--vendor/symfony/http-foundation/Tests/JsonResponseTest.php4
-rw-r--r--vendor/symfony/http-foundation/Tests/ResponseTest.php6
12 files changed, 76 insertions, 24 deletions
diff --git a/vendor/symfony/http-foundation/Cookie.php b/vendor/symfony/http-foundation/Cookie.php
index e6b8b798f2..1e22c745a0 100644
--- a/vendor/symfony/http-foundation/Cookie.php
+++ b/vendor/symfony/http-foundation/Cookie.php
@@ -18,6 +18,10 @@ namespace Symfony\Component\HttpFoundation;
*/
class Cookie
{
+ const SAMESITE_NONE = 'none';
+ const SAMESITE_LAX = 'lax';
+ const SAMESITE_STRICT = 'strict';
+
protected $name;
protected $value;
protected $domain;
@@ -25,13 +29,14 @@ class Cookie
protected $path;
protected $secure;
protected $httpOnly;
+
private $raw;
private $sameSite;
private $secureDefault = false;
- const SAMESITE_NONE = 'none';
- const SAMESITE_LAX = 'lax';
- const SAMESITE_STRICT = 'strict';
+ private static $reservedCharsList = "=,; \t\r\n\v\f";
+ private static $reservedCharsFrom = ['=', ',', ';', ' ', "\t", "\r", "\n", "\v", "\f"];
+ private static $reservedCharsTo = ['%3D', '%2C', '%3B', '%20', '%09', '%0D', '%0A', '%0B', '%0C'];
/**
* Creates cookie from raw header string.
@@ -93,7 +98,7 @@ class Cookie
}
// from PHP source code
- if (preg_match("/[=,; \t\r\n\013\014]/", $name)) {
+ if ($raw && false !== strpbrk($name, self::$reservedCharsList)) {
throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name));
}
@@ -141,7 +146,13 @@ class Cookie
*/
public function __toString()
{
- $str = ($this->isRaw() ? $this->getName() : urlencode($this->getName())).'=';
+ if ($this->isRaw()) {
+ $str = $this->getName();
+ } else {
+ $str = str_replace(self::$reservedCharsFrom, self::$reservedCharsTo, $this->getName());
+ }
+
+ $str .= '=';
if ('' === (string) $this->getValue()) {
$str .= 'deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; Max-Age=0';
diff --git a/vendor/symfony/http-foundation/HeaderBag.php b/vendor/symfony/http-foundation/HeaderBag.php
index 4f761c3bf6..7782f74244 100644
--- a/vendor/symfony/http-foundation/HeaderBag.php
+++ b/vendor/symfony/http-foundation/HeaderBag.php
@@ -121,7 +121,15 @@ class HeaderBag implements \IteratorAggregate, \Countable
}
if ($first) {
- return \count($headers[$key]) ? (string) $headers[$key][0] : $default;
+ if (!$headers[$key]) {
+ return $default;
+ }
+
+ if (null === $headers[$key][0]) {
+ return null;
+ }
+
+ return (string) $headers[$key][0];
}
return $headers[$key];
diff --git a/vendor/symfony/http-foundation/Response.php b/vendor/symfony/http-foundation/Response.php
index 168d5fce5e..1e616453c9 100644
--- a/vendor/symfony/http-foundation/Response.php
+++ b/vendor/symfony/http-foundation/Response.php
@@ -344,7 +344,7 @@ class Response
// cookies
foreach ($this->headers->getCookies() as $cookie) {
- header('Set-Cookie: '.$cookie->getName().strstr($cookie, '='), false, $this->statusCode);
+ header('Set-Cookie: '.$cookie, false, $this->statusCode);
}
// status
diff --git a/vendor/symfony/http-foundation/Session/Storage/Handler/RedisSessionHandler.php b/vendor/symfony/http-foundation/Session/Storage/Handler/RedisSessionHandler.php
index a6498b882c..46ca6796d8 100644
--- a/vendor/symfony/http-foundation/Session/Storage/Handler/RedisSessionHandler.php
+++ b/vendor/symfony/http-foundation/Session/Storage/Handler/RedisSessionHandler.php
@@ -34,8 +34,8 @@ class RedisSessionHandler extends AbstractSessionHandler
* List of available options:
* * prefix: The prefix to use for the keys in order to avoid collision on the Redis server.
*
- * @param \Redis|\RedisArray|\RedisCluster|\Predis\Client|RedisProxy $redis
- * @param array $options An associative array of options
+ * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|RedisProxy $redis
+ * @param array $options An associative array of options
*
* @throws \InvalidArgumentException When unsupported client or options are passed
*/
@@ -45,11 +45,11 @@ class RedisSessionHandler extends AbstractSessionHandler
!$redis instanceof \Redis &&
!$redis instanceof \RedisArray &&
!$redis instanceof \RedisCluster &&
- !$redis instanceof \Predis\Client &&
+ !$redis instanceof \Predis\ClientInterface &&
!$redis instanceof RedisProxy &&
!$redis instanceof RedisClusterProxy
) {
- throw new \InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, \is_object($redis) ? \get_class($redis) : \gettype($redis)));
+ throw new \InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, %s given', __METHOD__, \is_object($redis) ? \get_class($redis) : \gettype($redis)));
}
if ($diff = array_diff(array_keys($options), ['prefix'])) {
diff --git a/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php b/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php
index 5bdf5e2ac2..202f3a5a6a 100644
--- a/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php
+++ b/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php
@@ -458,7 +458,7 @@ class NativeSessionStorage implements SessionStorageInterface
foreach ($bags as $bag) {
$key = $bag->getStorageKey();
- $session[$key] = isset($session[$key]) ? $session[$key] : [];
+ $session[$key] = isset($session[$key]) && \is_array($session[$key]) ? $session[$key] : [];
$bag->initialize($session[$key]);
}
diff --git a/vendor/symfony/http-foundation/Tests/CookieTest.php b/vendor/symfony/http-foundation/Tests/CookieTest.php
index 61a278e656..55287e082d 100644
--- a/vendor/symfony/http-foundation/Tests/CookieTest.php
+++ b/vendor/symfony/http-foundation/Tests/CookieTest.php
@@ -24,10 +24,9 @@ use Symfony\Component\HttpFoundation\Cookie;
*/
class CookieTest extends TestCase
{
- public function invalidNames()
+ public function namesWithSpecialCharacters()
{
return [
- [''],
[',MyName'],
[';MyName'],
[' MyName'],
@@ -40,12 +39,26 @@ class CookieTest extends TestCase
}
/**
- * @dataProvider invalidNames
+ * @dataProvider namesWithSpecialCharacters
*/
- public function testInstantiationThrowsExceptionIfCookieNameContainsInvalidCharacters($name)
+ public function testInstantiationThrowsExceptionIfRawCookieNameContainsSpecialCharacters($name)
{
$this->expectException('InvalidArgumentException');
- Cookie::create($name);
+ Cookie::create($name, null, 0, null, null, null, false, true);
+ }
+
+ /**
+ * @dataProvider namesWithSpecialCharacters
+ */
+ public function testInstantiationSucceedNonRawCookieNameContainsSpecialCharacters($name)
+ {
+ $this->assertInstanceOf(Cookie::class, Cookie::create($name));
+ }
+
+ public function testInstantiationThrowsExceptionIfCookieNameIsEmpty()
+ {
+ $this->expectException('InvalidArgumentException');
+ Cookie::create('');
}
public function testInvalidExpiration()
diff --git a/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_urlencode.expected b/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_urlencode.expected
index 14e44a398a..17a9efc669 100644
--- a/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_urlencode.expected
+++ b/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_urlencode.expected
@@ -4,7 +4,8 @@ Array
[0] => Content-Type: text/plain; charset=utf-8
[1] => Cache-Control: no-cache, private
[2] => Date: Sat, 12 Nov 1955 20:04:00 GMT
- [3] => Set-Cookie: ?*():@&+$/%#[]=%3F%2A%28%29%3A%40%26%2B%24%2F%25%23%5B%5D; path=/
+ [3] => Set-Cookie: %3D%2C%3B%20%09%0D%0A%0B%0C=%3D%2C%3B%20%09%0D%0A%0B%0C; path=/
[4] => Set-Cookie: ?*():@&+$/%#[]=%3F%2A%28%29%3A%40%26%2B%24%2F%25%23%5B%5D; path=/
+ [5] => Set-Cookie: ?*():@&+$/%#[]=%3F%2A%28%29%3A%40%26%2B%24%2F%25%23%5B%5D; path=/
)
shutdown
diff --git a/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_urlencode.php b/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_urlencode.php
index c0363b829d..9ffb0dfec8 100644
--- a/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_urlencode.php
+++ b/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/cookie_urlencode.php
@@ -4,9 +4,12 @@ use Symfony\Component\HttpFoundation\Cookie;
$r = require __DIR__.'/common.inc';
-$str = '?*():@&+$/%#[]';
+$str1 = "=,; \t\r\n\v\f";
+$r->headers->setCookie(new Cookie($str1, $str1, 0, '', null, false, false, false, null));
-$r->headers->setCookie(new Cookie($str, $str, 0, '', null, false, false, false, null));
+$str2 = '?*():@&+$/%#[]';
+
+$r->headers->setCookie(new Cookie($str2, $str2, 0, '', null, false, false, false, null));
$r->sendHeaders();
-setcookie($str, $str, 0, '/');
+setcookie($str2, $str2, 0, '/');
diff --git a/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/invalid_cookie_name.php b/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/invalid_cookie_name.php
index 0afaaa8a57..3acf86039d 100644
--- a/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/invalid_cookie_name.php
+++ b/vendor/symfony/http-foundation/Tests/Fixtures/response-functional/invalid_cookie_name.php
@@ -5,7 +5,7 @@ use Symfony\Component\HttpFoundation\Cookie;
$r = require __DIR__.'/common.inc';
try {
- $r->headers->setCookie(Cookie::create('Hello + world', 'hodor'));
+ $r->headers->setCookie(new Cookie('Hello + world', 'hodor', 0, null, null, null, false, true));
} catch (\InvalidArgumentException $e) {
echo $e->getMessage();
}
diff --git a/vendor/symfony/http-foundation/Tests/HeaderBagTest.php b/vendor/symfony/http-foundation/Tests/HeaderBagTest.php
index a5876f9e3a..dcc266f69c 100644
--- a/vendor/symfony/http-foundation/Tests/HeaderBagTest.php
+++ b/vendor/symfony/http-foundation/Tests/HeaderBagTest.php
@@ -48,6 +48,13 @@ class HeaderBagTest extends TestCase
$this->assertInstanceOf('DateTime', $headerDate);
}
+ public function testGetDateNull()
+ {
+ $bag = new HeaderBag(['foo' => null]);
+ $headerDate = $bag->getDate('foo');
+ $this->assertNull($headerDate);
+ }
+
public function testGetDateException()
{
$this->expectException('RuntimeException');
@@ -96,6 +103,9 @@ class HeaderBagTest extends TestCase
$bag->set('foo', 'bor', false);
$this->assertEquals('bar', $bag->get('foo'), '->get return first value');
$this->assertEquals(['bar', 'bor'], $bag->get('foo', 'nope', false), '->get return all values as array');
+
+ $bag->set('baz', null);
+ $this->assertNull($bag->get('baz', 'nope'), '->get return null although different default value is given');
}
public function testSetAssociativeArray()
diff --git a/vendor/symfony/http-foundation/Tests/JsonResponseTest.php b/vendor/symfony/http-foundation/Tests/JsonResponseTest.php
index 3d981cd329..aa8441799b 100644
--- a/vendor/symfony/http-foundation/Tests/JsonResponseTest.php
+++ b/vendor/symfony/http-foundation/Tests/JsonResponseTest.php
@@ -43,7 +43,7 @@ class JsonResponseTest extends TestCase
$this->assertSame('0', $response->getContent());
$response = new JsonResponse(0.1);
- $this->assertEquals('0.1', $response->getContent());
+ $this->assertEquals(0.1, $response->getContent());
$this->assertIsString($response->getContent());
$response = new JsonResponse(true);
@@ -132,7 +132,7 @@ class JsonResponseTest extends TestCase
$response = JsonResponse::create(0.1);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
- $this->assertEquals('0.1', $response->getContent());
+ $this->assertEquals(0.1, $response->getContent());
$this->assertIsString($response->getContent());
$response = JsonResponse::create(true);
diff --git a/vendor/symfony/http-foundation/Tests/ResponseTest.php b/vendor/symfony/http-foundation/Tests/ResponseTest.php
index b20bb0b2a6..ad1f806d73 100644
--- a/vendor/symfony/http-foundation/Tests/ResponseTest.php
+++ b/vendor/symfony/http-foundation/Tests/ResponseTest.php
@@ -370,6 +370,12 @@ class ResponseTest extends ResponseTestCase
$this->assertNull($response->headers->get('Expires'), '->expire() removes the Expires header when the response is fresh');
}
+ public function testNullExpireHeader()
+ {
+ $response = new Response(null, 200, ['Expires' => null]);
+ $this->assertNull($response->getExpires());
+ }
+
public function testGetTtl()
{
$response = new Response();