[wp-trac] [WordPress Trac] #29807: add support for picture element and srcset attribute on img in wp_kses

WordPress Trac noreply at wordpress.org
Thu Oct 4 07:14:34 UTC 2018


#29807: add support for picture element and srcset attribute on img in wp_kses
-------------------------------------------------+-------------------------
 Reporter:  mattheu                              |       Owner:  (none)
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Formatting                           |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-      |     Focuses:
  refresh                                        |
-------------------------------------------------+-------------------------

Comment (by peterwilsoncc):

 I think it's fine to only worry about unencoded commas in the single URL
 attributes.

 For `srcset` you can safely split on the comma and assume any of the
 candidates' URL components will have commas and spaces encoded.

 {{{#!php
 <?php
 // At the top of the function
 $uris           = array( 'xmlns', 'profile' /* ... */ );
 $uri_candidates = array( 'srcset' );

 // Later in the function
 if ( in_array( strtolower( $attrname ), $uri_candidates ) ) {
    // Split into values as in your original patch
    $thesevals = preg_split( '/\s*,\s*/', $thisval );

 } elseif ( in_array( strtolower( $attrname ), $uris ) ) {
    // Maintain current validation
    $thesevals = array( $thisval );
 }

 // Validate $thesevals.
 }}}

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


More information about the wp-trac mailing list