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 1717fca

Browse filesBrowse files
[Cache] Add url decoding of password in RedisTrait DSN
1 parent 9780f09 commit 1717fca
Copy full SHA for 1717fca

File tree

3 files changed

+24
-8
lines changed
Filter options

3 files changed

+24
-8
lines changed

‎.github/workflows/integration-tests.yml

Copy file name to clipboardExpand all lines: .github/workflows/integration-tests.yml
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ jobs:
4848
image: redis:6.2.8
4949
ports:
5050
- 16379:6379
51+
redis-authenticated:
52+
image: redis:6.2.8
53+
ports:
54+
- 16380:6379
55+
env:
56+
REDIS_ARGS: "--requirepass p@ssword"
5157
redis-cluster:
5258
image: grokzen/redis-cluster:6.2.8
5359
ports:
@@ -172,6 +178,7 @@ jobs:
172178
run: ./phpunit --group integration -v
173179
env:
174180
REDIS_HOST: 'localhost:16379'
181+
REDIS_AUTHENTICATED_HOST: 'localhost:16380'
175182
REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005'
176183
REDIS_SENTINEL_HOSTS: 'localhost:26379 localhost:26379 localhost:26379'
177184
REDIS_SENTINEL_SERVICE: redis_sentinel

‎src/Symfony/Component/Cache/Tests/Traits/RedisTraitTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Traits/RedisTraitTest.php
+16-7Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@
1515
use PHPUnit\Framework\TestCase;
1616
use Symfony\Component\Cache\Traits\RedisTrait;
1717

18+
/**
19+
* @requires extension redis
20+
*/
1821
class RedisTraitTest extends TestCase
1922
{
20-
public static function setUpBeforeClass(): void
21-
{
22-
if (!getenv('REDIS_CLUSTER_HOSTS')) {
23-
throw new SkippedTestSuiteError('REDIS_CLUSTER_HOSTS env var is not defined.');
24-
}
25-
}
26-
2723
/**
2824
* @dataProvider provideCreateConnection
2925
*/
@@ -42,6 +38,19 @@ public function testCreateConnection(string $dsn, string $expectedClass)
4238
self::assertInstanceOf($expectedClass, $connection);
4339
}
4440

41+
public function testUrlDecodeParameters()
42+
{
43+
if (!getenv('REDIS_AUTHENTICATED_HOST')) {
44+
self::markTestSkipped('REDIS_AUTHENTICATED_HOST env var is not defined.');
45+
}
46+
47+
$mock = self::getObjectForTrait(RedisTrait::class);
48+
$connection = $mock::createConnection('redis://:p%40ssword@'.getenv('REDIS_AUTHENTICATED_HOST'));
49+
50+
self::assertInstanceOf(\Redis::class, $connection);
51+
self::assertSame('p@ssword', $connection->getAuth());
52+
}
53+
4554
public static function provideCreateConnection(): array
4655
{
4756
$hosts = array_map(function ($host) { return sprintf('host[%s]', $host); }, explode(' ', getenv('REDIS_CLUSTER_HOSTS')));

‎src/Symfony/Component/Cache/Traits/RedisTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Traits/RedisTrait.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static function createConnection(string $dsn, array $options = [])
105105

106106
$params = preg_replace_callback('#^'.$scheme.':(//)?(?:(?:[^:@]*+:)?([^@]*+)@)?#', function ($m) use (&$auth) {
107107
if (isset($m[2])) {
108-
$auth = $m[2];
108+
$auth = rawurldecode($m[2]);
109109

110110
if ('' === $auth) {
111111
$auth = null;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.