[wp-trac] [WordPress Trac] #43977: Fix error-prone string to array parsing

WordPress Trac noreply at wordpress.org
Thu Jan 10 21:05:55 UTC 2019


#43977: Fix error-prone string to array parsing
--------------------------------------+-----------------------
 Reporter:  flixos90                  |       Owner:  flixos90
     Type:  defect (bug)              |      Status:  closed
 Priority:  normal                    |   Milestone:  5.1
Component:  General                   |     Version:
 Severity:  normal                    |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests  |     Focuses:  rest-api
--------------------------------------+-----------------------
Changes (by flixos90):

 * owner:  (none) => flixos90
 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"44546" 44546]:
 {{{
 #!CommitTicketReference repository="" revision="44546"
 General: Fix problematic string to array parsing.

 WordPress has historically often used code like `preg_split( '/[\s,]+/',
 $var )` to parse a string of comma-separated values into an array.
 However, this approach was causing an empty string to not be parsed into
 an empty array as expected, but rather into an array with the empty string
 as its sole element.

 This was among other areas causing problems in the REST API where passing
 an empty request parameter could cause that request to fail because,
 instead of it being ignored, that parameter would be compared against the
 valid values for it, which typically do not include an empty string.

 Props david.binda, sstoqnov.
 Fixes #43977.
 }}}

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


More information about the wp-trac mailing list