8000 Merge branch '4.4' into 5.4 · symfony/symfony@e107069 · GitHub
[go: up one dir, main page]

Skip to content

Commit e107069

Browse files
Merge branch '4.4' into 5.4
* 4.4: [HttpFoundation] Update "[Session] Overwrite invalid session id" to only validate when files session storage is used [DoctrineBridge] Add missing break
2 parents f034bf1 + 07fa911 commit e107069

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ public function getTypes(string $class, string $property, array $context = [])
182182
case Types::SIMPLE_ARRAY:
183183
return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING))];
184184
}
185+
break;
185186
case Type::BUILTIN_TYPE_INT:
186187
case Type::BUILTIN_TYPE_STRING:
187188
if ($enumType) {

src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function start()
146146
}
147147

148148
$sessionId = $_COOKIE[session_name()] ?? null;
149-
if ($sessionId && !preg_match('/^[a-zA-Z0-9,-]{22,}$/', $sessionId)) {
149+
if ($sessionId && $this->saveHandler instanceof AbstractProxy && 'files' === $this->saveHandler->getSaveHandlerName() && !preg_match('/^[a-zA-Z0-9,-]{22,}$/', $sessionId)) {
150150
// the session ID in the header is invalid, create a new one
151151
session_id(session_create_id());
152152
}

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,31 @@ public function testGetBagsOnceSessionStartedIsIgnored()
287287
$this->assertEquals($storage->getBag('flashes'), $bag);
288288
}
289289

290-
public function testRegenerateInvalidSessionId()
290+
public function testRegenerateInvalidSessionIdForNativeFileSessionHandler()
291291
{
292292
$_COOKIE[session_name()] = '&~[';
293-
$started = (new NativeSessionStorage())->start();
293+
session_id('&~[');
294+
$storage = new NativeSessionStorage([], new NativeFileSessionHandler());
295+
$started = $storage->start();
294296

295297
$this->assertTrue($started);
296298
$this->assertMatchesRegularExpression('/^[a-zA-Z0-9,-]{22,}$/', session_id());
299+
$storage->save();
300+
301+
$_COOKIE[session_name()] = '&~[';
302+
session_id('&~[');
303+
$storage = new NativeSessionStorage([], new SessionHandlerProxy(new NativeFileSessionHandler()));
304+
$started = $storage->start();
305+
306+
$this->assertTrue($started);
307+
$this->assertMatchesRegularExpression('/^[a-zA-Z0-9,-]{22,}$/', session_id());
308+
$storage->save();
309+
310+
$_COOKIE[session_name()] = '&~[';
311+
session_id('&~[');
312+
$storage = new NativeSessionStorage([], new NullSessionHandler());
313+
$started = $storage->start();
314+
$this->assertTrue($started);
315+
$this->assertSame('&~[', session_id());
297316
}
298317
}

0 commit comments

Comments
 (0)
0