mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX Unquoted shortcodes weren't parsed (fixes #680)
Since that used to be the default shortcode notation for our core "insert media" functionality, its important to have this fixed and keep supporting "legacy" content created with 3.0.
This commit is contained in:
parent
a6b0807b9f
commit
0e5b099287
@ -151,7 +151,7 @@ class ShortcodeParser {
|
|||||||
(?:
|
(?:
|
||||||
(?:\'([^\']+)\') | # Value surrounded by \'
|
(?:\'([^\']+)\') | # Value surrounded by \'
|
||||||
(?:"([^"]+)") | # Value surrounded by "
|
(?:"([^"]+)") | # Value surrounded by "
|
||||||
(\w+) # Bare value
|
([^\s,\]]+) # Bare value
|
||||||
)
|
)
|
||||||
';
|
';
|
||||||
|
|
||||||
|
@ -150,13 +150,13 @@ class ShortcodeParserTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testUnquotedArguments() {
|
public function testUnquotedArguments() {
|
||||||
$this->assertEquals('', $this->parser->parse('[test_shortcode,foo=bar,baz = buz]'));
|
$this->assertEquals('', $this->parser->parse('[test_shortcode,foo=bar!,baz = buz123]'));
|
||||||
$this->assertEquals(array('foo' => 'bar', 'baz' => 'buz'), $this->arguments);
|
$this->assertEquals(array('foo' => 'bar!', 'baz' => 'buz123'), $this->arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSpacesForDelimiter() {
|
public function testSpacesForDelimiter() {
|
||||||
$this->assertEquals('', $this->parser->parse('[test_shortcode foo=bar baz = buz]'));
|
$this->assertEquals('', $this->parser->parse('[test_shortcode foo=bar! baz = buz123]'));
|
||||||
$this->assertEquals(array('foo' => 'bar', 'baz' => 'buz'), $this->arguments);
|
$this->assertEquals(array('foo' => 'bar!', 'baz' => 'buz123'), $this->arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSelfClosingTag() {
|
public function testSelfClosingTag() {
|
||||||
|
@ -62,10 +62,10 @@
|
|||||||
var content = jQuery(o.content);
|
var content = jQuery(o.content);
|
||||||
content.find('.ss-htmleditorfield-file.embed').each(function() {
|
content.find('.ss-htmleditorfield-file.embed').each(function() {
|
||||||
var el = jQuery(this);
|
var el = jQuery(this);
|
||||||
var shortCode = '[embed width=' + el.data('width')
|
var shortCode = '[embed width="' + el.data('width') + '"'
|
||||||
+ ' height=' + el.data('height')
|
+ ' height="' + el.data('height') + '"'
|
||||||
+ ' class=' + el.data('cssclass')
|
+ ' class="' + el.data('cssclass') + '"'
|
||||||
+ ' thumbnail=' + el.data('thumbnail')
|
+ ' thumbnail="' + el.data('thumbnail') + '"'
|
||||||
+ ']' + el.data('url')
|
+ ']' + el.data('url')
|
||||||
+ '[/embed]';
|
+ '[/embed]';
|
||||||
el.replaceWith(shortCode);
|
el.replaceWith(shortCode);
|
||||||
|
Loading…
Reference in New Issue
Block a user