Merge branch '5.1' into 5.2
* 5.1: parse cookie values containing the equal sign make some time dependent tests more resilient do not break when loading schemas from network paths on Windows
This commit is contained in:
commit
d3739d4482
@ -110,7 +110,7 @@ class DirectoryResourceTest extends TestCase
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
$time = time();
|
||||
sleep(1);
|
||||
usleep(1500000);
|
||||
unlink($this->directory.'/tmp.xml');
|
||||
$this->assertFalse($resource->isFresh($time), '->isFresh() returns false if an existing file is removed');
|
||||
}
|
||||
|
@ -604,6 +604,8 @@ class XmlFileLoader extends FileLoader
|
||||
array_shift($parts);
|
||||
$locationstart = 'phar:///';
|
||||
}
|
||||
} elseif ('\\' === \DIRECTORY_SEPARATOR && 0 === strpos($location, '\\\\')) {
|
||||
$locationstart = '';
|
||||
}
|
||||
$drive = '\\' === \DIRECTORY_SEPARATOR ? array_shift($parts).'/' : '';
|
||||
$location = $locationstart.$drive.implode('/', array_map('rawurlencode', $parts));
|
||||
|
@ -251,17 +251,23 @@ class HeaderUtils
|
||||
return $query;
|
||||
}
|
||||
|
||||
private static function groupParts(array $matches, string $separators): array
|
||||
private static function groupParts(array $matches, string $separators, bool $first = true): array
|
||||
{
|
||||
$separator = $separators[0];
|
||||
$partSeparators = substr($separators, 1);
|
||||
|
||||
$i = 0;
|
||||
$partMatches = [];
|
||||
$previousMatchWasSeparator = false;
|
||||
foreach ($matches as $match) {
|
||||
if (isset($match['separator']) && $match['separator'] === $separator) {
|
||||
if (!$first && $previousMatchWasSeparator && isset($match['separator']) && $match['separator'] === $separator) {
|
||||
$previousMatchWasSeparator = true;
|
||||
$partMatches[$i][] = $match;
|
||||
} elseif (isset($match['separator']) && $match['separator'] === $separator) {
|
||||
$previousMatchWasSeparator = true;
|
||||
++$i;
|
||||
} else {
|
||||
$previousMatchWasSeparator = false;
|
||||
$partMatches[$i][] = $match;
|
||||
}
|
||||
}
|
||||
@ -269,12 +275,19 @@ class HeaderUtils
|
||||
$parts = [];
|
||||
if ($partSeparators) {
|
||||
foreach ($partMatches as $matches) {
|
||||
$parts[] = self::groupParts($matches, $partSeparators);
|
||||
$parts[] = self::groupParts($matches, $partSeparators, false);
|
||||
}
|
||||
} else {
|
||||
foreach ($partMatches as $matches) {
|
||||
$parts[] = self::unquote($matches[0][0]);
|
||||
}
|
||||
|
||||
if (!$first && 2 < \count($parts)) {
|
||||
$parts = [
|
||||
$parts[0],
|
||||
implode($separator, \array_slice($parts, 1)),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $parts;
|
||||
|
@ -326,6 +326,12 @@ class CookieTest extends TestCase
|
||||
|
||||
$cookie = Cookie::fromString('foo', true);
|
||||
$this->assertEquals(Cookie::create('foo', null, 0, '/', null, false, false, false, null), $cookie);
|
||||
|
||||
$cookie = Cookie::fromString('foo_cookie=foo=1&bar=2&baz=3; expires=Tue, 22-Sep-2020 06:27:09 GMT; path=/');
|
||||
$this->assertEquals(Cookie::create('foo_cookie', 'foo=1&bar=2&baz=3', strtotime('Tue, 22-Sep-2020 06:27:09 GMT'), '/', null, false, false, true, null), $cookie);
|
||||
|
||||
$cookie = Cookie::fromString('foo_cookie=foo==; expires=Tue, 22-Sep-2020 06:27:09 GMT; path=/');
|
||||
$this->assertEquals(Cookie::create('foo_cookie', 'foo==', strtotime('Tue, 22-Sep-2020 06:27:09 GMT'), '/', null, false, false, true, null), $cookie);
|
||||
}
|
||||
|
||||
public function testFromStringWithHttpOnly()
|
||||
|
@ -16,33 +16,47 @@ use Symfony\Component\HttpFoundation\HeaderUtils;
|
||||
|
||||
class HeaderUtilsTest extends TestCase
|
||||
{
|
||||
public function testSplit()
|
||||
/**
|
||||
* @dataProvider provideHeaderToSplit
|
||||
*/
|
||||
public function testSplit(array $expected, string $header, string $separator)
|
||||
{
|
||||
$this->assertSame(['foo=123', 'bar'], HeaderUtils::split('foo=123,bar', ','));
|
||||
$this->assertSame(['foo=123', 'bar'], HeaderUtils::split('foo=123, bar', ','));
|
||||
$this->assertSame([['foo=123', 'bar']], HeaderUtils::split('foo=123; bar', ',;'));
|
||||
$this->assertSame([['foo=123'], ['bar']], HeaderUtils::split('foo=123, bar', ',;'));
|
||||
$this->assertSame(['foo', '123, bar'], HeaderUtils::split('foo=123, bar', '='));
|
||||
$this->assertSame(['foo', '123, bar'], HeaderUtils::split(' foo = 123, bar ', '='));
|
||||
$this->assertSame([['foo', '123'], ['bar']], HeaderUtils::split('foo=123, bar', ',='));
|
||||
$this->assertSame([[['foo', '123']], [['bar'], ['foo', '456']]], HeaderUtils::split('foo=123, bar; foo=456', ',;='));
|
||||
$this->assertSame([[['foo', 'a,b;c=d']]], HeaderUtils::split('foo="a,b;c=d"', ',;='));
|
||||
$this->assertSame($expected, HeaderUtils::split($header, $separator));
|
||||
}
|
||||
|
||||
$this->assertSame(['foo', 'bar'], HeaderUtils::split('foo,,,, bar', ','));
|
||||
$this->assertSame(['foo', 'bar'], HeaderUtils::split(',foo, bar,', ','));
|
||||
$this->assertSame(['foo', 'bar'], HeaderUtils::split(' , foo, bar, ', ','));
|
||||
$this->assertSame(['foo bar'], HeaderUtils::split('foo "bar"', ','));
|
||||
$this->assertSame(['foo bar'], HeaderUtils::split('"foo" bar', ','));
|
||||
$this->assertSame(['foo bar'], HeaderUtils::split('"foo" "bar"', ','));
|
||||
public function provideHeaderToSplit(): array
|
||||
{
|
||||
return [
|
||||
[['foo=123', 'bar'], 'foo=123,bar', ','],
|
||||
[['foo=123', 'bar'], 'foo=123, bar', ','],
|
||||
[[['foo=123', 'bar']], 'foo=123; bar', ',;'],
|
||||
[[['foo=123'], ['bar']], 'foo=123, bar', ',;'],
|
||||
[['foo', '123, bar'], 'foo=123, bar', '='],
|
||||
[['foo', '123, bar'], ' foo = 123, bar ', '='],
|
||||
[[['foo', '123'], ['bar']], 'foo=123, bar', ',='],
|
||||
[[[['foo', '123']], [['bar'], ['foo', '456']]], 'foo=123, bar; foo=456', ',;='],
|
||||
[[[['foo', 'a,b;c=d']]], 'foo="a,b;c=d"', ',;='],
|
||||
|
||||
// These are not a valid header values. We test that they parse anyway,
|
||||
// and that both the valid and invalid parts are returned.
|
||||
$this->assertSame([], HeaderUtils::split('', ','));
|
||||
$this->assertSame([], HeaderUtils::split(',,,', ','));
|
||||
$this->assertSame(['foo', 'bar', 'baz'], HeaderUtils::split('foo, "bar", "baz', ','));
|
||||
$this->assertSame(['foo', 'bar, baz'], HeaderUtils::split('foo, "bar, baz', ','));
|
||||
$this->assertSame(['foo', 'bar, baz\\'], HeaderUtils::split('foo, "bar, baz\\', ','));
|
||||
$this->assertSame(['foo', 'bar, baz\\'], HeaderUtils::split('foo, "bar, baz\\\\', ','));
|
||||
[['foo', 'bar'], 'foo,,,, bar', ','],
|
||||
[['foo', 'bar'], ',foo, bar,', ','],
|
||||
[['foo', 'bar'], ' , foo, bar, ', ','],
|
||||
[['foo bar'], 'foo "bar"', ','],
|
||||
[['foo bar'], '"foo" bar', ','],
|
||||
[['foo bar'], '"foo" "bar"', ','],
|
||||
|
||||
[[['foo_cookie', 'foo=1&bar=2&baz=3'], ['expires', 'Tue, 22-Sep-2020 06:27:09 GMT'], ['path', '/']], 'foo_cookie=foo=1&bar=2&baz=3; expires=Tue, 22-Sep-2020 06:27:09 GMT; path=/', ';='],
|
||||
[[['foo_cookie', 'foo=='], ['expires', 'Tue, 22-Sep-2020 06:27:09 GMT'], ['path', '/']], 'foo_cookie=foo==; expires=Tue, 22-Sep-2020 06:27:09 GMT; path=/', ';='],
|
||||
[[['foo_cookie', 'foo=a=b'], ['expires', 'Tue, 22-Sep-2020 06:27:09 GMT'], ['path', '/']], 'foo_cookie=foo="a=b"; expires=Tue, 22-Sep-2020 06:27:09 GMT; path=/', ';='],
|
||||
|
||||
// These are not a valid header values. We test that they parse anyway,
|
||||
// and that both the valid and invalid parts are returned.
|
||||
[[], '', ','],
|
||||
[[], ',,,', ','],
|
||||
[['foo', 'bar', 'baz'], 'foo, "bar", "baz', ','],
|
||||
[['foo', 'bar, baz'], 'foo, "bar, baz', ','],
|
||||
[['foo', 'bar, baz\\'], 'foo, "bar, baz\\', ','],
|
||||
[['foo', 'bar, baz\\'], 'foo, "bar, baz\\\\', ','],
|
||||
];
|
||||
}
|
||||
|
||||
public function testCombine()
|
||||
|
@ -22,6 +22,9 @@ use Symfony\Component\Mime\Email;
|
||||
use Symfony\Component\Mime\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Mime\RawMessage;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class SmtpTransportTest extends TestCase
|
||||
{
|
||||
public function testToString()
|
||||
@ -83,7 +86,7 @@ class SmtpTransportTest extends TestCase
|
||||
$this->assertNotContains("NOOP\r\n", $stream->getCommands());
|
||||
|
||||
$stream->clearCommands();
|
||||
sleep(1);
|
||||
usleep(1500000);
|
||||
|
||||
$transport->send(new RawMessage('Message 3'), $envelope);
|
||||
$this->assertContains("NOOP\r\n", $stream->getCommands());
|
||||
|
Reference in New Issue
Block a user