[wp-trac] [WordPress Trac] #47164: map_deep in formatting.php do not handle null-byte

WordPress Trac noreply at wordpress.org
Fri Nov 11 11:59:37 UTC 2022


#47164: map_deep in formatting.php do not handle null-byte
---------------------------------------------------+---------------------
 Reporter:  bitcomplex                             |       Owner:  (none)
     Type:  defect (bug)                           |      Status:  new
 Priority:  normal                                 |   Milestone:  6.2
Component:  Formatting                             |     Version:  5.2.2
 Severity:  critical                               |  Resolution:
 Keywords:  has-patch has-unit-tests dev-feedback  |     Focuses:
---------------------------------------------------+---------------------

Comment (by cadic):

 With the suggested solution, the function

 {{{#!php
 <?php
 $actual = map_deep(
         (object) array(
                 'var0'   => '1',
                 chr( 0 ) => (object) array(
                         'var0'   => '2',
                         chr( 0 ) => '3',
                 ),
                 'var1'   => (object) array(
                         'var0'   => '4',
                         chr( 0 ) => '5',
                 ),
         ),
         'intval'
 );
 }}}

 It will return an object:


 {{{
 object(stdClass) (3) {
   ["var0"]=>
   int(1)
   ["\0"]=>
   object(stdClass) (2) {
     ["var0"]=>
     string(1) "2" // <-- intval wasn't applied, parent key is \0
     ["\0"]=>
     string(1) "3" // <-- intval wasn't applied, parent key is \0
   }
   ["var1"]=>
   object(stdClass) (2) {
     ["var0"]=>
     int(4)
     ["\0"]=>
     string(1) "5" // <-- intval wasn't applied, key is \0
   }
 }
 }}}

 It's better than a Fatal error, but that also means that map_deep hasn't
 applied the callback properly to all nested properties.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47164#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list