File tree Expand file tree Collapse file tree
src/Ratchet/Session/Serialize
tests/unit/Session/Serialize Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323 - " 8.0"
2424 - " 8.1"
2525 - " 8.2"
26+ - " 8.3"
2627 dependencies :
2728 - " highest"
2829 include :
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ composer require cboden/ratchet:^0.4.4
101101See also the [ CHANGELOG] ( CHANGELOG.md ) for details about version upgrades.
102102
103103This project aims to run on any platform and thus does not require any PHP
104- extensions and supports running on legacy PHP 5.4 through PHP 8.2 + with limited support for newer PHP.
104+ extensions and supports running on legacy PHP 5.4 through PHP 8.3 + with limited support for newer PHP.
105105It's * highly recommended to use the latest supported PHP version* for this project.
106106
107107See above note about [ Reviving Ratchet] ( #reviving-ratchet ) for newer PHP support.
Original file line number Diff line number Diff line change @@ -22,7 +22,10 @@ public function unserialize($raw) {
2222 $ offset += 1 ;
2323 $ varname = substr ($ raw , $ offset , $ num );
2424 $ offset += $ num ;
25- $ data = unserialize (substr ($ raw , $ offset ));
25+
26+ // try to unserialize one piece of data from current offset, ignoring any warnings for trailing data on PHP 8.3+
27+ // @link https://wiki.php.net/rfc/unserialize_warn_on_trailing_data
28+ $ data = @unserialize (substr ($ raw , $ offset ));
2629
2730 $ returnData [$ varname ] = $ data ;
2831 $ offset += strlen (serialize ($ data ));
Original file line number Diff line number Diff line change @@ -38,7 +38,10 @@ public function unserialize($raw) {
3838 $ num = $ pos - $ offset ;
3939 $ varname = substr ($ raw , $ offset , $ num );
4040 $ offset += $ num + 1 ;
41- $ data = unserialize (substr ($ raw , $ offset ));
41+
42+ // try to unserialize one piece of data from current offset, ignoring any warnings for trailing data on PHP 8.3+
43+ // @link https://wiki.php.net/rfc/unserialize_warn_on_trailing_data
44+ $ data = @unserialize (substr ($ raw , $ offset ));
4245
4346 $ returnData [$ varname ] = $ data ;
4447 $ offset += strlen (serialize ($ data ));
Original file line number Diff line number Diff line change 1+ <?php
2+ namespace Ratchet \Session \Serialize ;
3+ use PHPUnit \Framework \TestCase ;
4+ use Ratchet \Session \Serialize \PhpBinaryHandler ;
5+
6+ /**
7+ * @covers Ratchet\Session\Serialize\PhpHandler
8+ */
9+ class PhpBinaryHandlerTest extends TestCase {
10+ protected $ _handler ;
11+
12+ /**
13+ * @before
14+ */
15+ public function setUpHandler () {
16+ $ this ->_handler = new PhpBinaryHandler ;
17+ }
18+
19+ public function serializedProvider () {
20+ return array (
21+ array (
22+ "\x0f" . '_sf2_attributes ' . 'a:2:{s:5:"hello";s:5:"world";s:4:"last";i:1332872102;} ' . "\x0c" . '_sf2_flashes ' . 'a:0:{} '
23+ , array (
24+ '_sf2_attributes ' => array (
25+ 'hello ' => 'world '
26+ , 'last ' => 1332872102
27+ )
28+ , '_sf2_flashes ' => array ()
29+ )
30+ )
31+ );
32+ }
33+
34+ /**
35+ * @dataProvider serializedProvider
36+ */
37+ public function testUnserialize ($ in , $ expected ) {
38+ $ this ->assertEquals ($ expected , $ this ->_handler ->unserialize ($ in ));
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments