Merge pull request #7808 from creative-commoners/pulls/4.0/fix-html5-parsing-embeds

FIX Allow cleanup marker regex to handle self closing HTML5 tags
This commit is contained in:
Damian Mooyman 2018-01-31 10:24:34 +13:00 committed by GitHub
commit ab6428ef59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -726,7 +726,7 @@ class ShortcodeParser
$content = preg_replace_callback(
// Not a general-case parser; assumes that the HTML generated in replaceElementTagsWithMarkers()
// hasn't been heavily modified
'/<img[^>]+class="' . preg_quote(self::$marker_class) . '"[^>]+data-tagid="([^"]+)"[^>]+>/i',
'/<img[^>]+class="' . preg_quote(self::$marker_class) . '"[^>]+data-tagid="([^"]+)"[^>]*>/i',
function ($matches) use ($tags, $parser) {
$tag = $tags[$matches[1]];
return $parser->getShortcodeReplacementText($tag);

View File

@ -328,6 +328,17 @@ class ShortcodeParserTest extends SapphireTest
$stub->parse('<p>test</p>');
}
public function testSelfClosingHtmlTags()
{
$this->parser->register('img', function () {
return '<img src="http://example.com/image.jpg">';
});
$result = $this->parser->parse('[img]');
$this->assertContains('http://example.com/image.jpg', $result);
}
// -----------------------------------------------------------------------------------------------------------------
/**