Skip to content

Commit f72b21a

Browse files
committed
Shortcodes: don't allow unclosed HTML elements in attributes
Merges [34134] for 4.3 branch Built from https://develop.svn.wordpress.org/branches/4.3@34144 git-svn-id: http://core.svn.wordpress.org/branches/4.3@34112 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent f91a5fd commit f72b21a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Diff for: wp-includes/media.php

+2
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,8 @@ function img_caption_shortcode( $attr, $content = null ) {
863863
$content = $matches[1];
864864
$attr['caption'] = trim( $matches[2] );
865865
}
866+
} elseif ( strpos( $attr['caption'], '<' ) !== false ) {
867+
$attr['caption'] = wp_kses( $attr['caption'], 'post' );
866868
}
867869

868870
/**

Diff for: wp-includes/shortcodes.php

+9
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,15 @@ function shortcode_parse_atts($text) {
462462
elseif (isset($m[8]))
463463
$atts[] = stripcslashes($m[8]);
464464
}
465+
466+
// Reject any unclosed HTML elements
467+
foreach( $atts as &$value ) {
468+
if ( false !== strpos( $value, '<' ) ) {
469+
if ( 1 !== preg_match( '/^[^<]*+(?:<[^>]*+>[^<]*+)*+$/', $value ) ) {
470+
$value = '';
471+
}
472+
}
473+
}
465474
} else {
466475
$atts = ltrim($text);
467476
}

0 commit comments

Comments
 (0)