From 8f915c0b5269b4235342e78ffa28daee96b3b2a4 Mon Sep 17 00:00:00 2001 From: Tomasz Kowalczyk Date: Mon, 25 Apr 2016 23:22:52 +0200 Subject: [PATCH] fixed issue with syntax tags in the shortcode content: they caused RegularParser to return empty content as if shortcode was self-closed --- src/Parser/RegularParser.php | 3 ++- tests/ParserTest.php | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Parser/RegularParser.php b/src/Parser/RegularParser.php index 8a42422..de40d51 100644 --- a/src/Parser/RegularParser.php +++ b/src/Parser/RegularParser.php @@ -123,7 +123,8 @@ private function content(array &$names) $appendContent = function(array $token) use(&$content) { $content .= $token[1]; }; while($this->position < $this->tokensCount) { - while($this->match(array(self::TOKEN_STRING, self::TOKEN_WS), $appendContent)) { + while($this->position < $this->tokensCount && false === $this->lookahead(self::TOKEN_OPEN)) { + $this->match(null, $appendContent); continue; } diff --git a/tests/ParserTest.php b/tests/ParserTest.php index b3d1e96..e64d4cc 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -191,6 +191,14 @@ public function provideShortcodes() new ParsedShortcode(new Shortcode('n_am_e', array(), null), '[n_am_e]', 24), new ParsedShortcode(new Shortcode('_n_', array(), null), '[_n_]', 32), )), + array($s, '[x]/[/x] [x]"[/x] [x]=[/x] [x]][/x] [x] [/x] [x]x[/x]', array( + new ParsedShortcode(new Shortcode('x', array(), '/'), '[x]/[/x]', 0), + new ParsedShortcode(new Shortcode('x', array(), '"'), '[x]"[/x]', 9), + new ParsedShortcode(new Shortcode('x', array(), '='), '[x]=[/x]', 18), + new ParsedShortcode(new Shortcode('x', array(), ']'), '[x]][/x]', 27), + new ParsedShortcode(new Shortcode('x', array(), ' '), '[x] [/x]', 36), + new ParsedShortcode(new Shortcode('x', array(), 'x'), '[x]x[/x]', 45), + )), ); /**