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

WordPress Trac noreply at wordpress.org
Fri Feb 22 20:13:01 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 fclaussen):

 Replying to [comment:19 fclaussen]:
 > I am still not sure how, but this broken an important function I have.
 > I am trying to determine why, since I am passing a string to
 `sanitize_text_field` and it is being converted to an empty string.
 >
 > If I ever figure this out, I'll update here.

 Ok. I figure out the issue I was having.
 I read from xml, sanitize this string and then create a post with the
 string.

 Problem is that what was considered a "string" before, is actually an
 SimpleXMLElement object.
 Switching to `sanitize_text_field( (string) $myvar->title )` did the
 trick.

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


More information about the wp-trac mailing list