[wp-trac] [WordPress Trac] #41450: sanitize_text_field() assumes the field is a string

WordPress Trac noreply at wordpress.org
Fri Feb 22 20:32:16 UTC 2019


#41450: sanitize_text_field() assumes the field is a string
--------------------------+---------------------
 Reporter:  johnbillion   |       Owner:  pento
     Type:  defect (bug)  |      Status:  closed
 Priority:  low           |   Milestone:  5.1
Component:  Formatting    |     Version:  2.9
 Severity:  normal        |  Resolution:  fixed
 Keywords:                |     Focuses:
--------------------------+---------------------

Comment (by iCaleb):

 I ran into the same as the above with the SimpleXMLElement. It has a magic
 `__toString()` method that gets called when you do that type conversion.

 Perhaps an extra check should be added for better backwards compatibility?

 {{{#!php
 if ( ( is_object( $str ) && ! method_exists( $str, '__toString' ) ) ||
 is_array( $str ) ) {
   return '';
 }
 }}}

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


More information about the wp-trac mailing list