[wp-trac] [WordPress Trac] #55962: Upgrade `sanitize_hex_color()` to CSS Color Level 4

WordPress Trac noreply at wordpress.org
Mon Jun 13 23:11:17 UTC 2022

#55962: Upgrade `sanitize_hex_color()` to CSS Color Level 4
 Reporter:  anrghg                               |       Owner:  (none)
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Formatting                           |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  needs-patch needs-unit-tests dev-    |     Focuses:  css
  feedback                                       |

Comment (by peterwilsoncc):

 I'm of the view the purpose of the sanitize functions is to validate
 against the spec, given a hex colour can now be 3,4,6 or 8 characters the
 core function should account for that.

 Accepting @ocean90's point though, it might be worth introducing
 `sanitize_color()` or `sanitize_css_color()` to validate
 [http://developer.mozilla.org/en-US/docs/Web/CSS/color the many valid
 color formats] that WordPress has no way of validating.

 This new function could be documented to indicate that the length of the
 value may change as new color functions are introduced to the CSS spec.

Ticket URL: <https://core.trac.wordpress.org/ticket/55962#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list