From c430a82236394e522810da05af7ca15bf9348168 Mon Sep 17 00:00:00 2001 From: Nikolay Bachiyski Date: Mon, 14 Sep 2015 22:35:22 +0000 Subject: [PATCH] Shortcodes: don't allow unclosed HTML elements in attributes git-svn-id: https://develop.svn.wordpress.org/trunk@34134 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/media.php | 2 ++ src/wp-includes/shortcodes.php | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index 7a58329c82..2e8d7a3010 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -870,6 +870,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/src/wp-includes/shortcodes.php b/src/wp-includes/shortcodes.php index 45df890e3e..e28e2b52f7 100644 --- a/src/wp-includes/shortcodes.php +++ b/src/wp-includes/shortcodes.php @@ -462,6 +462,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); }