Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ENHANCEMENT Shortcodes now support commas as delimiter for attributes…

… (thanks aoneil for help with the regex!) (trac #6868)

BUGFIX HtmlEditorField not inserting shortcodes correctly (trac #6868)
  • Loading branch information...
commit 49267dbbc46422d27cfaa81bc131c2dea679df9f 1 parent c59c717
@halkyon halkyon authored
View
4 javascript/HtmlEditorField.js
@@ -370,7 +370,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
// All other attributes
switch(this.find(':input[name=LinkType]:checked').val()) {
case 'internal':
- href = '[sitetree_link id=' + this.find(':input[name=internal]').val() + ']';
+ href = '[sitetree_link,id=' + this.find(':input[name=internal]').val() + ']';
if(anchor) href += '#' + anchor;
break;
@@ -379,7 +379,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
break;
case 'file':
- href = '[file_link id=' + this.find(':input[name=file]').val() + ']';
+ href = '[file_link,id=' + this.find(':input[name=file]').val() + ']';
target = '_blank';
break;
View
5 parsers/ShortcodeParser.php
@@ -170,10 +170,9 @@ protected function handleShortcode($matches) {
if($prefix == '[' && $suffix == ']') {
return substr($matches[0], 1, -1);
}
-
$attributes = array(); // Parse attributes into into this array.
- if(preg_match_all('/(\w+) *= *(?:([\'"])(.*?)\\2|([^ "\'>]+))/', $matches[3], $match, PREG_SET_ORDER)) {
+ if(preg_match_all('/(\w+) *= *(?:([\'"])(.*?)\\2|([^ ,"\'>]+))/', $matches[3], $match, PREG_SET_ORDER)) {
foreach($match as $attribute) {
if(!empty($attribute[4])) {
$attributes[strtolower($attribute[1])] = $attribute[4];
@@ -186,4 +185,4 @@ protected function handleShortcode($matches) {
return $prefix . call_user_func($this->shortcodes[$shortcode], $attributes, $matches[5], $this, $shortcode) . $suffix;
}
-}
+}
View
6 tests/parsers/ShortcodeParserTest.php
@@ -82,14 +82,14 @@ public function testShortcodeEscaping() {
}
public function testUnquotedArguments() {
- $this->assertEquals('', $this->parser->parse('[test_shortcode foo=bar baz = buz]'));
+ $this->assertEquals('', $this->parser->parse('[test_shortcode,foo=bar,baz = buz]'));
$this->assertEquals(array('foo' => 'bar', 'baz' => 'buz'), $this->arguments);
}
public function testSelfClosingTag() {
$this->assertEquals (
'morecontent',
- $this->parser->parse('[test_shortcode id="1"/]more[test_shortcode id="2"]content[/test_shortcode]'),
+ $this->parser->parse('[test_shortcode,id="1"/]more[test_shortcode,id="2"]content[/test_shortcode]'),
'Assert that self-closing tags are respected during parsing.'
);
@@ -109,4 +109,4 @@ public function shortcodeSaver($arguments, $content = null, $parser, $tagName =
return $content;
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.