mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FIX Allow cleanup marker regex to handle self closing HTML5 tags
This commit is contained in:
parent
c7e341c67d
commit
3d7ecc5240
@ -726,7 +726,7 @@ class ShortcodeParser
|
|||||||
$content = preg_replace_callback(
|
$content = preg_replace_callback(
|
||||||
// Not a general-case parser; assumes that the HTML generated in replaceElementTagsWithMarkers()
|
// Not a general-case parser; assumes that the HTML generated in replaceElementTagsWithMarkers()
|
||||||
// hasn't been heavily modified
|
// 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) {
|
function ($matches) use ($tags, $parser) {
|
||||||
$tag = $tags[$matches[1]];
|
$tag = $tags[$matches[1]];
|
||||||
return $parser->getShortcodeReplacementText($tag);
|
return $parser->getShortcodeReplacementText($tag);
|
||||||
|
@ -328,6 +328,17 @@ class ShortcodeParserTest extends SapphireTest
|
|||||||
$stub->parse('<p>test</p>');
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user