8000 Merge branch '6.4' into 7.1 · symfony/symfony@40ace7f · GitHub
[go: up one dir, main page]

8000 Skip to content

Commit 40ace7f

Browse files
committed
Merge branch '6.4' into 7.1
* 6.4: fix merge [Intl] Update ICU data from 74.1 to 75.1 use DeprecatedCallableInfo for Twig callables if possible [Filesystem] Add a warning about `chown()` and `chgrp()` on Windows [String] Update wcswidth data with Unicode 16 PhpSubprocess: Add flag PREG_OFFSET_CAPTURE to preg_match to identify the offset Work around parse_url() bug [Ldap] Clean `ldap_connect()` call in `LdapTestCase` [HttpFoundation] Update links for X-Accel-Redirect and fail properly when X-Accel-Mapping is missing
2 parents f2910d5 + e4863db commit 40ace7f

File tree

161 files changed

+1072
-951
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+1072
-951
lines changed

src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Console\Output\OutputInterface;
1919
use Symfony\Component\Console\Tester\CommandCompletionTester;
2020
use Symfony\Component\Console\Tester\CommandTester;
21+
use Twig\DeprecatedCallableInfo;
2122
use Twig\Environment;
2223
use Twig\Loader\FilesystemLoader;
2324
use Twig\TwigFilter;
@@ -159,7 +160,12 @@ private function createCommandTester(): CommandTester
159160
private function createCommand(): Command
160161
{
161162
$environment = new Environment(new FilesystemLoader(\dirname(__DIR__).'/Fixtures/templates/'));
162-
$environment->addFilter(new TwigFilter('deprecated_filter', fn ($v) => $v, ['deprecated' => true]));
163+
if (class_exists(DeprecatedCallableInfo::class)) {
164+
$options = ['deprecation_info' => new DeprecatedCallableInfo('foo/bar', '1.1')];
165+
} else {
166+
$options = ['deprecated' => true];
167+
}
168+
$environment->addFilter(new TwigFilter('deprecated_filter', fn ($v) => $v, $options));
163169

164170
$command = new LintCommand($environment);
165171

src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,17 @@ public function urlRedirectAction(Request $request, string $path, bool $permanen
115115
$statusCode = $permanent ? 301 : 302;
116116
}
117117

118+
$scheme ??= $request->getScheme();
119+
120+
if (str_starts_with($path, '//')) {
121+
$path = $scheme.':'.$path;
122+
}
123+
118124
// redirect if the path is a full URL
119125
if (parse_url($path, \PHP_URL_SCHEME)) {
120126
return new RedirectResponse($path, $statusCode);
121127
}
122128

123-
$scheme ??= $request->getScheme();
124-
125129
if ($qs = $request->server->get('QUERY_STRING') ?: $request->getQueryString()) {
126130
if (!str_contains($path, '?')) {
127131
$qs = '?'.$qs;

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,20 @@ public function testFullURLWithMethodKeep()
183183
$this->assertEquals(307, $returnResponse->getStatusCode());
184184
}
185185

186+
public function testProtocolRelative()
187+
{
188+
$request = new Request();
189+
$controller = new RedirectController();
190+
191+
$returnResponse = $controller->urlRedirectAction($request, '//foo.bar/');
192+
$this->assertRedirectUrl($returnResponse, 'http://foo.bar/');
193+
$this->assertSame(302, $returnResponse->getStatusCode());
194+
195+
$returnResponse = $controller->urlRedirectAction($request, '//foo.bar/', false, 'https');
196+
$this->assertRedirectUrl($returnResponse, 'https://foo.bar/');
197+
$this->assertSame(302, $returnResponse->getStatusCode());
198+
}
199+
186200
public function testUrlRedirectDefaultPorts()
187201
{
188202
$host = 'www.example.com';

src/Symfony/Component/DomCrawler/Tests/UriResolverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public static function provideResolverTests()
8686
['foo', 'http://localhost#bar', 'http://localhost/foo'],
8787

8888
['http://', 'http://localhost', 'http://'],
89+
['/foo:123', 'http://localhost', 'http://localhost/foo:123'],
8990
];
9091
}
9192
}

src/Symfony/Component/DomCrawler/UriResolver.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ public static function resolve(string $uri, ?string $baseUri): string
3232
{
3333
$uri = trim($uri);
3434

35+
if (false === ($scheme = parse_url($uri, \PHP_URL_SCHEME)) && '/' === ($uri[0] ?? '')) {
36+
$scheme = parse_url($uri.'#', \PHP_URL_SCHEME);
37+
}
38+
3539
// absolute URL?
36-
if (null !== parse_url($uri, \PHP_URL_SCHEME)) {
40+
if (null !== $scheme) {
3741
return $uri;
3842
}
3943

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ public function chmod(string|iterable $files, int $mode, int $umask = 0000, bool
223223
/**
224224
* Change the owner of an array of files or directories.
225225
*
226+
* This method always throws on Windows, as the underlying PHP function is not supported.
227+
* @see https://www.php.net/chown
228+
*
226229
* @param string|int $user A user name or number
227230
* @param bool $recursive Whether change the owner recursively or not
228231
*
@@ -249,6 +252,9 @@ public function chown(string|iterable $files, string|int $user, bool $recursive
249252
/**
250253
* Change the group of an array of files or directories.
251254
*
255+
* This method always throws on Windows, as the underlying PHP function is not supported.
256+
* @see https://www.php.net/chgrp
257+
*
252258
* @param string|int $group A group name or number
253259
* @param bool $recursive Whether change the group recursively or not
254260
*

src/Symfony/Component/HttpClient/HttpClientTrait.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,10 @@ private static function resolveUrl(array $url, ?array $base, array $queryDefault
627627
private static function parseUrl(string $url, array $query = [], array $allowedSchemes = ['http' => 80, 'https' => 443]): array
628628
{
629629
if (false === $parts = parse_url($url)) {
630-
throw new InvalidArgumentException(sprintf('Malformed URL "%s".', $url));
630+
if ('/' !== ($url[0] ?? '') || false === $parts = parse_url($url.'#')) {
631+
throw new InvalidArgumentException(sprintf('Malformed URL "%s".', $url));
632+
}
633+
unset($parts['fragment']);
631634
}
632635

633636
if ($query) {

src/Symfony/Component/HttpClient/NativeHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ private static function createRedirectResolver(array $options, string $host, str
414414

415415
[$host, $port] = self::parseHostPort($url, $info);
416416

417-
if (false !== (parse_url($location, \PHP_URL_HOST) ?? false)) {
417+
if (false !== (parse_url($location.'#', \PHP_URL_HOST) ?? false)) {
418418
// Authorization and Cookie headers MUST NOT follow except for the initial host name
419419
$requestHeaders = $redirectHeaders['host'] === $host && $redirectHeaders['port'] === $port ? $redirectHeaders['with_auth'] : $redirectHeaders['no_auth'];
420420
$requestHeaders[] = 'Host: '.$host.$port;

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,12 @@ public function prepare(Request $request): static
218218
}
219219
if ('x-accel-redirect' === strtolower($type)) {
220220
// Do X-Accel-Mapping substitutions.
221-
// @link https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/#x-accel-redirect
222-
$parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping', ''), ',=');
221+
// @link https://github.com/rack/rack/blob/main/lib/rack/sendfile.rb
222+
// @link https://mattbrictson.com/blog/accelerated-rails-downloads
223+
if (!$request->headers->has('X-Accel-Mapping')) {
224+
throw new \LogicException('The "X-Accel-Mapping" header must be set when "X-Sendfile-Type" is set to "X-Accel-Redirect".');
225+
}
226+
$parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping'), ',=');
223227
foreach ($parts as $part) {
224228
[$pathPrefix, $location] = $part;
225229
if (str_starts_with($path, $pathPrefix)) {

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ public static function create(string $uri, string $method = 'GET', array $parame
302302
if (false === $components) {
303303
throw new \InvalidArgumentException(sprintf('Malformed URI "%s".', $uri));
304304
}
305+
305306
if (isset($components['host'])) {
306307
$server['SERVER_NAME'] = $components['host'];
307308
$server['HTTP_HOST'] = $components['host'];

0 commit comments

Comments
 (0)
0