diff --git a/wp-includes/media.php b/wp-includes/media.php index 5e94cfeb36..d501dce239 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -801,6 +801,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 98f3908b38..e9f156e25e 100644 --- a/wp-includes/shortcodes.php +++ b/wp-includes/shortcodes.php @@ -461,6 +461,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); }