[wp-trac] [WordPress Trac] #52932: Rest Api enum validation does not work correctly WordPress 5.7

WordPress Trac noreply at wordpress.org
Sun Apr 4 18:05:25 UTC 2021


#52932: Rest Api enum validation does not work correctly WordPress 5.7
---------------------------------------------+-----------------------
 Reporter:  stefanjoebstl                    |       Owner:  yakimun
     Type:  defect (bug)                     |      Status:  closed
 Priority:  normal                           |   Milestone:  5.7.1
Component:  REST API                         |     Version:  5.7
 Severity:  normal                           |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests commit  |     Focuses:  rest-api
---------------------------------------------+-----------------------
Changes (by SergeyBiryukov):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"50653" 50653]:
 {{{
 #!CommitTicketReference repository="" revision="50653"
 REST API: Correct `enum` validation for numeric values.

 When validating `enum` values as `integer` or `number`, consider a number
 with a zero fractional part to be equivalent to an integer of the same
 value.

 In `rest_are_values_equal()`, when comparing two values of type `int` or
 `float` (in any combination), first cast both of them to `float` and then
 compare.

 This matches some test cases from the official JSON Schema test suite.

 Follow-up to [50010].

 Props yakimun, stefanjoebstl, TimothyBlynJacobs, rachelbaker.
 Fixes #52932.
 }}}

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


More information about the wp-trac mailing list