8000 Merge branch '3.4' into 4.3 · symfony/symfony@2ac5609 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2ac5609

Browse files
committed
Merge branch '3.4' into 4.3
* 3.4: [Validator] Allow underscore character "_" in URL username and password [SecurityBundle] Passwords are not encoded when algorithm set to \"true\" do not validate passwords when the hash is null [DI] Fix making the container path-independent when the app is in /app Allow copy instead of symlink for ./link script [FrameworkBundle] resolve service locators in `debug:*` commands bumped Symfony version to 3.4.37 updated VERSION for 3.4.36 update CONTRIBUTORS for 3.4.36 updated CHANGELOG for 3.4.36
2 parents 56fac41 + 5807f5f commit 2ac5609

File tree

11 files changed

+91
-45
lines changed

11 files changed

+91
-45
lines changed

CONTRIBUTORS.md

Lines changed: 50 additions & 29 deletions
Large diffs are not rendered by default.

link

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ use Symfony\Component\Filesystem\Filesystem;
2323
* @author Kévin Dunglas <dunglas@gmail.com>
2424
*/
2525

26+
$copy = false !== $k = array_search('--copy', $argv, true);
27+
$copy && array_splice($argv, $k, 1);
2628
$pathToProject = $argv[1] ?? getcwd();
2729

2830
if (!is_dir("$pathToProject/vendor/symfony")) {
29-
echo 'Link dependencies to components to a local clone of the main symfony/symfony GitHub repository.'.PHP_EOL.PHP_EOL;
30-
echo "Usage: $argv[0] /path/to/the/project".PHP_EOL.PHP_EOL;
31+
echo 'Link (or copy) dependencies to components to a local clone of the main symfony/symfony GitHub repository.'.PHP_EOL.PHP_EOL;
32+
echo "Usage: $argv[0] /path/to/the/project".PHP_EOL;
33+
echo ' Use `--copy` to copy dependencies instead of symlink'.PHP_EOL.PHP_EOL;
3134
echo "The directory \"$pathToProject\" does not exist or the dependencies are not installed, did you forget to run \"composer install\" in your project?".PHP_EOL;
3235
exit(1);
3336
}
@@ -50,7 +53,7 @@ foreach ($directories as $dir) {
5053

5154
foreach (glob("$pathToProject/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
5255
$package = 'symfony/'.basename($dir);
53-
if (is_link($dir)) {
56+
if (!$copy && is_link($dir)) {
5457
echo "\"$package\" is already a symlink, skipping.".PHP_EOL;
5558
continue;
5659
}
@@ -59,11 +62,17 @@ foreach (glob("$pathToProject/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as
5962
continue;
6063
}
6164

62-
$sfDir = '\\' === DIRECTORY_SEPARATOR ? $sfPackages[$package] : $filesystem->makePathRelative($sfPackages[$package], dirname(realpath($dir)));
65+
$sfDir = ('\\' === DIRECTORY_SEPARATOR || $copy) ? $sfPackages[$package] : $filesystem->makePathRelative($sfPackages[$package], dirname(realpath($dir))); 6D40
6366

6467
$filesystem->remove($dir);
65-
$filesystem->symlink($sfDir, $dir);
66-
echo "\"$package\" has been linked to \"$sfPackages[$package]\".".PHP_EOL;
68+
69+
if ($copy) {
70+
$filesystem->mirror($sfDir, $dir);
71+
echo "\"$package\" has been copied from \"$sfPackages[$package]\".".PHP_EOL;
72+
} else {
73+
$filesystem->symlink($sfDir, $dir);
74+
echo "\"$package\" has been linked to \"$sfPackages[$package]\".".PHP_EOL;
75+
}
6776
}
6877

6978
foreach (glob("$pathToProject/var/cache/*", GLOB_NOSORT) as $cacheDir) {

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\Console\Input\InputOption;
2222
use Symfony\Component\Console\Output\OutputInterface;
2323
use Symfony\Component\Console\Style\SymfonyStyle;
24+
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
2425
use Symfony\Component\DependencyInjection\ContainerBuilder;
2526
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
2627
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
@@ -229,6 +230,8 @@ protected function getContainerBuilder()
229230
$container->compile();
230231
} else {
231232
(new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
233+
$locatorPass = new ServiceLocatorTagPass();
234+
$locatorPass->process($container);
232235
}
233236

234237
return $this->containerBuilder = $container;

src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,13 @@ private function addEncodersSection(ArrayNodeDefinition $rootNode)
399399
->performNoDeepMerging()
400400
->beforeNormalization()->ifString()->then(function ($v) { return ['algorithm' => $v]; })->end()
401401
->children()
402-
->scalarNode('algorithm')->cannotBeEmpty()->end()
402+
->scalarNode('algorithm')
403+
->cannotBeEmpty()
404+
->validate()
405+
->ifTrue(function ($v) { return !\is_string($v); })
406+
->thenInvalid('You must provide a string value.')
407+
->end()
408+
->end()
403409
->scalarNode('hash_algorithm')->info('Name of hashing algorithm for PBKDF2 (i.e. sha256, sha512, etc..) See hash_algos() for a list of supported algorithms.')->defaultValue('sha512')->end()
404410
->scalarNode('key_length')->defaultValue(40)->end()
405411
->booleanNode('ignore_case')->defaultFalse()->end()

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,14 @@ public function dump(array $options = [])
194194
if (!empty($options['file']) && is_dir($dir = \dirname($options['file']))) {
195195
// Build a regexp where the first root dirs are mandatory,
196196
// but every other sub-dir is optional up to the full path in $dir
197-
// Mandate at least 2 root dirs and not more that 5 optional dirs.
197+
// Mandate at least 1 root dir and not more than 5 optional dirs.
198198

199199
$dir = explode(\DIRECTORY_SEPARATOR, realpath($dir));
200200
$i = \count($dir);
201201

202-
if (3 <= $i) {
202+
if (2 + (int) ('\\' === \DIRECTORY_SEPARATOR) <= $i) {
203203
$regex = '';
204-
$lastOptionalDir = $i > 8 ? $i - 5 : 3;
204+
$lastOptionalDir = $i > 8 ? $i - 5 : (2 + (int) ('\\' === \DIRECTORY_SEPARATOR));
205205
$this->targetDirMaxMatches = $i - $lastOptionalDir;
206206

207207
while (--$i >= $lastOptionalDir) {

src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function checkAuthentication(UserInterface $user, UsernamePasswordToke
5454
throw new BadCredentialsException('The presented password cannot be empty.');
5555
}
5656

57-
if (!$this->encoderFactory->getEncoder($user)->isPasswordValid($user->getPassword(), $presentedPassword, $user->getSalt())) {
57+
if (null === $user->getPassword() || !$this->encoderFactory->getEncoder($user)->isPasswordValid($user->getPassword(), $presentedPassword, $user->getSalt())) {
5858
throw new BadCredentialsException('The presented password is invalid.');
5959
}
6060
}

src/Symfony/Component/Security/Core/Encoder/UserPasswordEncoder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public function encodePassword(UserInterface $user, $plainPassword)
4242
*/
4343
public function isPasswordValid(UserInterface $user, $raw)
4444
{
45+
if (null === $user->getPassword()) {
46+
return false;
47+
}
48+
4549
$encoder = $this->encoderFactory->getEncoder($user);
4650

4751
return $encoder->isPasswordValid($user->getPassword(), $raw, $user->getSalt());

src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider;
1616
use Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder;
1717
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
18+
use Symfony\Component\Security\Core\User\User;
1819

1920
class DaoAuthenticationProviderTest extends TestCase
2021
{
@@ -151,7 +152,7 @@ public function testCheckAuthenticationWhenCredentialsAre0()
151152

152153
$method->invoke(
153154
$provider,
154-
$this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(),
155+
new User('username', 'password'),
155156
$token
156157
);
157158
}
@@ -175,7 +176,7 @@ public function testCheckAuthenticationWhenCredentialsAreNotValid()
175176
->willReturn('foo')
176177
;
177178

178-
$method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token);
179+
$method->invoke($provider, new User('username', 'password'), $token);
179180
}
180181

181182
public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChanged()
@@ -247,7 +248,7 @@ public function testCheckAuthentication()
247248
->willReturn('foo')
248249
;
249250

250-
$method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token);
251+
$method->invoke($provider, new User('username', 'password'), $token);
251252
}
252253

253254
protected function getSupportedToken()

src/Symfony/Component/Security/Core/Validator/Constraints/UserPasswordValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function validate($password, Constraint $constraint)
5353

5454
$encoder = $this->encoderFactory->getEncoder($user);
5555

56-
if (!$encoder->isPasswordValid($user->getPassword(), $password, $user->getSalt())) {
56+
if (null === $user->getPassword() || !$encoder->isPasswordValid($user->getPassword(), $password, $user->getSalt())) {
5757
$this->context->addViolation($constraint->message);
5858
}
5959
}

src/Symfony/Component/Validator/Constraints/UrlValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class UrlValidator extends ConstraintValidator
2424
{
2525
const PATTERN = '~^
2626
(%s):// # protocol
27-
(([\.\pL\pN-]+:)?([\.\pL\pN-]+)@)? # basic auth
27+
(([\_\.\pL\pN-]+:)?([\_\.\pL\pN-]+)@)? # basic auth
2828
(
2929
([\pL\pN\pS\-\_\.])+(\.?([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
3030
| # or

src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@ public function getValidUrls()
152152
['http://☎.com/'],
153153
['http://username:password@symfony.com'],
154154
['http://user.name:password@symfony.com'],
155+
['http://user_name:pass_word@symfony.com'],
155156
['http://username:pass.word@symfony.com'],
156157
['http://user.name:pass.word@symfony.com'],
157158
['http://user-name@symfony.com'],
159+
['http://user_name@symfony.com'],
158160
['http://symfony.com?'],
159161
['http://symfony.com?query=1'],
160162
['http://symfony.com/?query=1'],

0 commit comments

Comments
 (0)
0