php-serialize icon indicating copy to clipboard operation
php-serialize copied to clipboard

Use PHP's serialization methods from Ruby.

Results 9 php-serialize issues
Sort by recently updated
recently updated
newest added

Thanks for your contribution. I just used your gem and found an issue when working with Unicode characters. Here original serialized string from wordpress: ``` "a:2:{s:7:\"mau-sac\";a:6:{s:4:\"name\";s:10:\"Màu sắc\";s:5:\"value\";s:4:\"Xanh\";s:8:\"position\";s:1:\"0\";s:10:\"is_visible\";i:1;s:12:\"is_variation\";i:0;s:11:\"is_taxonomy\";i:0;}s:7:\"xuat-xu\";a:6:{s:4:\"name\";s:11:\"Xuất xứ\";s:5:\"value\";s:10:\"Việt Nam\";s:8:\"position\";s:1:\"1\";s:10:\"is_visible\";i:1;s:12:\"is_variation\";i:0;s:11:\"is_taxonomy\";i:0;}}" ```...

The following error is thrown: ``` TypeError: Unable to unserialize type ';' php-serialize-1.1.0/lib/php_serialize.rb:308:in `do_unserialize' ``` ``` json a:9:{s:7:"xxxxxxx";s:12:"xxxxxxxxxäxx";s:11:"description";s:12:"xxxxxxxxxäxx";s:8:"xxxxxxxx";s:7:"xxxxxxx";s:7:"xxxxxxx";s:0:"";s:8:"xxxxxxxx";s:0:"";s:6:"xxxxxx";a:1:{i:1;s:15:"xxxxxxxxxxxxxxx";}s:7:"xxxxxxx";a:1:{i:0;N;}s:4:"xxxx";a:9:{i:0;s:7:"xxxxxxx";i:1;s:8:"xxxxxxxx";i:2;s:6:"xxxxxx";i:3;s:8:"xxxxxxxx";i:4;s:6:"xxxxxx";i:5;s:10:"xxxxxxxxxx";i:6;s:4:"xxxx";i:7;s:5:"xxxxx";i:8;s:6:"xxxxxx";}s:6:"xxxxxx";a:25:{s:8:"xxxxxxxx";a:4:{s:7:"xxxxxxx";s:0:"";s:6:"xxxxxx";s:0:"";s:5:"xxxxx";s:0:"";s:6:"xxxxxx";s:0:"";}s:7:"xxxxxxx";a:4:{s:7:"xxxxxxx";s:11:"Üxxxxxxxxxx";s:6:"xxxxxx";s:4:"xxxx";s:5:"xxxxx";s:0:"";s:6:"xxxxxx";s:0:"";}s:10:"subxxxxxxx";a:4:{s:7:"xxxxxxx";s:11:"xxxxxxxxxxx";s:6:"xxxxxx";s:4:"xxxx";s:5:"xxxxx";s:0:"";s:6:"xxxxxx";s:0:"";}s:7:"xxxxxxx";a:4:{s:7:"xxxxxxx";s:4:"xxxx";s:6:"xxxxxx";s:8:"xxxxxxxx";s:5:"xxxxx";s:0:"";s:6:"xxxxxx";s:0:"";}s:6:"xxxxxx";a:4:{s:7:"xxxxxxx";s:0:"";s:6:"xxxxxx";s:0:"";s:5:"xxxxx";s:0:"";s:6:"xxxxxx";s:0:"";}s:8:"xxxxxxxx";a:4:{s:7:"xxxxxxx";s:0:"";s:6:"xxxxxx";s:0:"";s:5:"xxxxx";s:0:"";s:6:"xxxxxx";s:0:"";}s:6:"xxxxxx";a:4:{s:7:"xxxxxxx";s:0:"";s:6:"xxxxxx";s:0:"";s:5:"xxxxx";s:0:"";s:6:"xxxxxx";s:0:"";}s:8:"xxxxxxxx";a:4:{s:7:"xxxxxxx";s:0:"";s:6:"xxxxxx";s:0:"";s:5:"xxxxx";s:0:"";s:6:"xxxxxx";s:0:"";}s:13:"xxxxxxxxxxxxx";a:4:{s:7:"xxxxxxx";s:0:"";s:6:"xxxxxx";s:0:"";s:5:"xxxxx";s:0:"";s:6:"xxxxxx";s:0:"";}s:15:"xxxxxxxxxxxxxxx";a:4:{s:7:"xxxxxxx";s:0:"";s:6:"xxxxxx";s:0:"";s:5:"xxxxx";s:0:"";s:6:"xxxxxx";s:0:"";}s:17:"xxxxxxxxxxxxxxxxx";a:4:{s:7:"xxxxxxx";s:0:"";s:6:"xxxxxx";s:0:"";s:5:"xxxxx";s:0:"";s:6:"xxxxxx";s:0:"";}s:6:"xxxxxx";a:4:{s:7:"xxxxxxx";s:0:"";s:6:"xxxxxx";s:0:"";s:5:"xxxxx";s:0:"";s:6:"xxxxxx";s:0:"";}s:6:"xxxxxx";a:4:{s:7:"xxxxxxx";s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:"xxxxxxx";a:4:{s:7:"xxxxxxx";s:14:"xxxxxxx-xxxxxx";s:6:"xxxxxx";s:6:"xxxxxx";s:5:"xxxxx";s:0:"";s:6:"xxxxxx";s:0:"";}s:5:"xxxxx";a:4:{s:7:"xxxxxxx";s:5:"xxxxx";s:6:"xxxxxx";s:0:"";s:5:"xxxxx";s:0:"";s:6:"xxxxxx";s:0:"";}s:6:"xxxxxx";a:4:{s:7:"xxxxxxx";s:0:"";s:6:"xxxxxx";s:0:"";s:5:"xxxxx";s:0:"";s:6:"xxxxxx";s:0:"";}}} ```

Multibyte strings were not being encoded back into UTF-8, so I wrote a test case (and fixed the bug)

It seems that a couple of the latest commits break hashes / arrays with multibyte characters. I've written a failing test case, and the error message is the following: ```...

The docs suggest `PHP.unserialize` with `assoc = true` should return an array of key value pair arrays when a zero indexed, incrementing, associative array is encountered. ```ruby # If a...

While the "R" (Reference) type rarely appears in real-world PHP serialization, certain applications may use it. (at least I met it and saw `Unable to unserialize type 'R'` error.) >...

## Problem stdClass object may appears twice or more with difference properties as shown in the example below: ```php echo serialize([(object)["foo" => 1], (object)["bar" => 2]]); # => # a:2:{i:0;O:8:"stdClass":1:{s:3:"foo";i:1;}i:1;O:8:"stdClass":1:{s:3:"bar";i:2;}}...

The issue is the library is trusting the string size announced in the serialized data. Taking this correct PHP session… ``` encryption_key|s:32:"abcdefghijklmnopqrstuvwxyzabcdef";session_id|i:42; ``` …`PHP.unserialize` will correctly parse as ``` {"encryption_key"...

I have a PHP sessions files generated by PHP where the 2 first keys are surrounded by spaces (I really don't know why), which makes the parser crashes. ```diff -session_id|i:42;user_data|a:1:{s:3:"uid";i:666;}blabla_key|N;is_foo|b:0...