Shortcodes: Improve the reliablity of shortcodes inside HTML tags.

Props miqrogroove.

See #15694.



git-svn-id: https://develop.svn.wordpress.org/trunk@33359 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2015-07-22 05:14:50 +00:00
parent 7439dd7354
commit 7b41adf712
6 changed files with 722 additions and 45 deletions

View File

@@ -403,6 +403,82 @@ EOF;
}
}
/**
* Check for bugginess using normal input with latest patches.
*
* @dataProvider data_escaping
*/
function test_escaping( $input, $output ) {
return $this->assertEquals( $output, do_shortcode( $input ) );
}
function data_escaping() {
return array(
array(
'<!--[if lt IE 7]>',
'<!--[if lt IE 7]>',
),
array(
'[gallery title="<div>hello</div>"]',
'',
),
array(
'[caption caption="test" width="2"]<div>hello</div>[/caption]',
'<div style="width: 12px" class="wp-caption alignnone"><div>hello</div><p class="wp-caption-text">test</p></div>',
),
array(
'<div [gallery]>',
'<div >',
),
array(
'<div [[gallery]]>',
'<div [gallery]>',
),
array(
'[gallery]<div>Hello</div>[/gallery]',
'',
),
);
}
/**
* Check for bugginess using normal input with latest patches.
*
* @dataProvider data_escaping2
*/
function test_escaping2( $input, $output ) {
return $this->assertEquals( $output, strip_shortcodes( $input ) );
}
function data_escaping2() {
return array(
array(
'<!--[if lt IE 7]>',
'<!--[if lt IE 7]>',
),
array(
'[gallery title="<div>hello</div>"]',
'',
),
array(
'[caption caption="test" width="2"]<div>hello</div>[/caption]',
'',
),
array(
'<div [gallery]>', // Shortcodes will never be stripped inside elements.
'<div [gallery]>',
),
array(
'<div [[gallery]]>', // Shortcodes will never be stripped inside elements.
'<div [[gallery]]>',
),
array(
'[gallery]<div>Hello</div>[/gallery]',
'',
),
);
}
/**
* @ticket 26343
*/