-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
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.
-session_id|i:42;user_data|a:1:{s:3:"uid";i:666;}blabla_key|N;is_foo|b:0
+ session_id |i:42; user_data |a:1:{s:3:"uid";i:666;}blabla_key|N;is_foo|b:0/home/noraj/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/bundler/gems/php-serialize-68c0b6f9a20c/lib/php_serialize.rb:270:in 'PHP.do_unserialize': Unable to unserialize type ' ' (TypeError)
raise TypeError, "Unable to unserialize type '#{type}'"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from /home/noraj/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/bundler/gems/php-serialize-68c0b6f9a20c/lib/php_serialize.rb:174:in 'PHP.unserialize'
from formatter_jqr_php-serialize.rb:16:in '<main>'
It's due to the regexp here not taking spaces into accounts
php-serialize/lib/php_serialize.rb
Line 168 in 68c0b6f
| while string.string[string.pos, 32] =~ /^(\w+)\|/ # session_name|serialized_data |
As a quick fix I modified the regexp to take into account when the key is surrounded by spaces.
- while string.string[string.pos, 32] =~ /^(\w+)\|/ # session_name|serialized_data
+ while string.string[string.pos, 32] =~ /^\s*(\w+)\s*\|/ # session_name|serialized_dataI don't know if it is the best solution.
Metadata
Metadata
Assignees
Labels
No labels