[wp-trac] [WordPress Trac] #9930: is_serialized() returns false on serialized doubles

WordPress Trac wp-trac at lists.automattic.com
Tue Dec 22 12:55:02 UTC 2009


#9930: is_serialized() returns false on serialized doubles
---------------------------------+------------------------------------------
 Reporter:  vladimir_kolesnikov  |       Owner:  westi                       
     Type:  defect (bug)         |      Status:  reviewing                   
 Priority:  normal               |   Milestone:  3.0                         
Component:  General              |     Version:                              
 Severity:  minor                |    Keywords:  needs-patch needs-unit-tests
---------------------------------+------------------------------------------

Comment(by dd32):

 change that to:
 {{{
 return is_string($data) &&
 preg_match('/^(N;)|([aOs]:[0-9]+:.*[;}])|([bid]:[0-9.E+-]+;)$/s', $data);
 }}}

 ie. Add the s modifier and it passes this test case for me.

 {{{
         function test_is_serialized() {
                 $cases = array(
                                            serialize("a\nb"),
                                            serialize(-25),
                                            serialize(25),
                                            serialize(false),
                                            serialize(null),
                                            serialize(array()),
                                            serialize(1.1),
                                            serialize(2.1E+200),
                                            serialize( (object)array('test'
 => true, '3', 4) )
                                            );

                 foreach ( $cases as $case )
                         $this->assertTrue( is_serialized($case) );

         }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9930#comment:10>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list