diff --git a/parsers/ShortcodeParser.php b/parsers/ShortcodeParser.php index 95c1ae7ad..2bd2d34fc 100644 --- a/parsers/ShortcodeParser.php +++ b/parsers/ShortcodeParser.php @@ -256,9 +256,18 @@ class ShortcodeParser extends Object { preg_match_all(static::attrrx(), $match['attrs'][0], $attrmatches, PREG_SET_ORDER); foreach ($attrmatches as $attr) { - list($whole, $name, $value) = array_values(array_filter($attr)); + $name = ''; + $value = ''; + $parts = array_values(array_filter($attr)); + //the first element in the array is the complete delcaration (`id=1`) - we don't need this + array_shift($parts); + + //the next two parts are what we care about (id and 1 from `id=1`) + $name = array_shift($parts) ?: $name; + $value = array_shift($parts) ?: $value; + $attrs[$name] = $value; - } + } } // And store the indexes, tag details, etc diff --git a/tests/parsers/ShortcodeParserTest.php b/tests/parsers/ShortcodeParserTest.php index f28d5bc27..701a825e7 100644 --- a/tests/parsers/ShortcodeParserTest.php +++ b/tests/parsers/ShortcodeParserTest.php @@ -224,6 +224,14 @@ class ShortcodeParserTest extends SapphireTest { ); } + public function testFalseyArguments() { + $this->parser->parse('
[test_shortcode falsey=0]'); + + $this->assertEquals(array( + 'falsey' => '', + ), $this->arguments); + } + public function testNumericShortcodes() { $this->assertEqualsIgnoringWhitespace( '[2]',