Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit af1bb1f

Browse files
committed
add test for null byte in session data
1 parent 251238d commit af1bb1f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,21 @@ public function testWithLazySavePathConnection()
106106
@unlink($dbFile);
107107
}
108108

109-
public function testReadWriteRead()
109+
public function testReadWriteReadWithNullByte()
110110
{
111+
$sessionData = 'da' . "\0" . 'ta';
112+
111113
$storage = new PdoSessionHandler($this->pdo);
112114
$storage->open('', 'sid');
113-
$data = $storage->read('id');
114-
$storage->write('id', 'data');
115+
$readData = $storage->read('id');
116+
$storage->write('id', $sessionData);
115117
$storage->close();
116-
$this->assertSame('', $data, 'New session returns empty string data');
118+
$this->assertSame('', $readData, 'New session returns empty string data');
117119

118120
$storage->open('', 'sid');
119-
$data = $storage->read('id');
121+
$readData = $storage->read('id');
120122
$storage->close();
121-
$this->assertSame('data', $data, 'Written value can be read back correctly');
123+
$this->assertSame($sessionData, $readData, 'Written value can be read back correctly');
122124
}
123125

124126
/**

0 commit comments

Comments
 (0)