Make WordPress Core

Changeset 34145


Ignore:
Timestamp:
09/14/2015 10:47:19 PM (11 years ago)
Author:
nbachiyski
Message:

Shortcodes: don't allow unclosed HTML elements in attributes

Merges [34134] for 4.2 branch

Location:
branches/4.2/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2/src/wp-includes/media.php

    r32113 r34145  
    848848                        $attr['caption'] = trim( $matches[2] );
    849849                }
     850        } elseif ( strpos( $attr['caption'], '<' ) !== false ) {
     851                $attr['caption'] = wp_kses( $attr['caption'], 'post' );
    850852        }
    851853
  • branches/4.2/src/wp-includes/shortcodes.php

    r33518 r34145  
    458458                                $atts[] = stripcslashes($m[8]);
    459459                }
     460
     461                // Reject any unclosed HTML elements
     462                foreach( $atts as &$value ) {
     463                        if ( false !== strpos( $value, '<' ) ) {
     464                                if ( 1 !== preg_match( '/^[^<]*+(?:<[^>]*+>[^<]*+)*+$/', $value ) ) {
     465                                        $value = '';
     466                                }
     467                        }
     468                }
    460469        } else {
    461470                $atts = ltrim($text);
Note: See TracChangeset for help on using the changeset viewer.