WordPress.org

Make WordPress Core

Changeset 33600


Ignore:
Timestamp:
08/09/2015 08:48:02 PM (6 years ago)
Author:
ocean90
Message:

Shortcodes: Trim whitespace after sanitizing the shortcode output.

props Ankit K Gupta, obenland, miqrogroove.
fixes #33259.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/shortcodes.php

    r33594 r33600  
    400400                    // Sanitize the shortcode output using KSES.
    401401                    $new_attr = wp_kses_one_attr( $new_attr, $elname );
    402                     if ( '' !== $new_attr ) {
     402                    if ( '' !== trim( $new_attr ) ) {
    403403                        // The shortcode is safe to use now.
    404404                        $attr = $new_attr;
  • trunk/tests/phpunit/tests/shortcode.php

    r33594 r33600  
    420420            ),
    421421            array(
     422                '1 <a href="[test-shortcode-tag]"> 2 <a href="[test-shortcode-tag]" >',
     423                '1 <a href=""> 2 <a href="" >',
     424            ),
     425            array(
     426                '1 <a noise="[test-shortcode-tag]"> 2 <a noise=" [test-shortcode-tag] " >',
     427                '1 <a noise="[test-shortcode-tag]"> 2 <a noise=" [test-shortcode-tag] " >',
     428            ),
     429            array(
    422430                '[gallery title="<div>hello</div>"]',
    423431                '',
Note: See TracChangeset for help on using the changeset viewer.