diff --git a/wp-includes/media.php b/wp-includes/media.php index b69b328d13..35ecdd9569 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -847,6 +847,8 @@ function img_caption_shortcode( $attr, $content = null ) { $content = $matches[1]; $attr['caption'] = trim( $matches[2] ); } + } elseif ( strpos( $attr['caption'], '<' ) !== false ) { + $attr['caption'] = wp_kses( $attr['caption'], 'post' ); } /** diff --git a/wp-includes/shortcodes.php b/wp-includes/shortcodes.php index 531a1fa186..810db20076 100644 --- a/wp-includes/shortcodes.php +++ b/wp-includes/shortcodes.php @@ -457,6 +457,15 @@ function shortcode_parse_atts($text) { elseif (isset($m[8])) $atts[] = stripcslashes($m[8]); } + + // Reject any unclosed HTML elements + foreach( $atts as &$value ) { + if ( false !== strpos( $value, '<' ) ) { + if ( 1 !== preg_match( '/^[^<]*+(?:<[^>]*+>[^<]*+)*+$/', $value ) ) { + $value = ''; + } + } + } } else { $atts = ltrim($text); }