FIX Allow cleanup marker regex to handle self closing HTML5 tags

This commit is contained in:
Robbie Averill 2018-01-30 11:15:20 +13:00
parent c7e341c67d
commit 3d7ecc5240
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);
}
// -----------------------------------------------------------------------------------------------------------------
/**