diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 112e37b..52a7c89 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -42,7 +42,7 @@ jobs: - name: 'Psalm' run: | composer remove --dev -W 'phpunit/phpunit' - composer require --dev -W 'vimeo/psalm=>=5.0' 'nikic/php-parser=>=4.0' + composer require --dev -W 'vimeo/psalm=>=5.0 <7.0' 'nikic/php-parser=>=4.0' php vendor/bin/psalm --shepherd --php-version=${{ matrix.php }} continue-on-error: '${{ matrix.failure }}' diff --git a/src/Utility/RegexBuilderUtility.php b/src/Utility/RegexBuilderUtility.php index 1f04e77..8639901 100644 --- a/src/Utility/RegexBuilderUtility.php +++ b/src/Utility/RegexBuilderUtility.php @@ -60,7 +60,7 @@ private static function createShortcodeRegexContent(SyntaxInterface $syntax) // lookahead test for space, closing tag, self-closing tag or end of string $empty = '(?=\s|'.$close.'|'.$slash.$space.$close.'|$)'; // equals sign and alphanumeric value - $simple = '((?:(?!=\s*|'.$close.'|'.$slash.$close.')[^\s])+)'; + $simple = '((?:(?!'.$equals.'\s*|'.$close.'|'.$slash.$close.')[^\s])+)'; // equals sign and value without unescaped string delimiters enclosed in them $complex = $string.'(?:[^'.$string.'\\\\]*(?:\\\\.[^'.$string.'\\\\]*)*)'.$string; // complete parameters matching regex diff --git a/tests/ParserTest.php b/tests/ParserTest.php index fa0bd60..85249e6 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -101,6 +101,16 @@ public function testParser(ParserInterface $parser, $code, array $expected) $this->assertShortcodes($parser->parse($code), $expected); } + public function testParsersEndValuesAtSyntaxSeparator() + { + $syntax = new Syntax('@', '#', '!', '&', '~'); + foreach(array(new RegexParser($syntax), new RegularParser($syntax), new StackParser($syntax), new HybridParser($syntax)) as $parser) { + $this->assertShortcodes($parser->parse('@a&c=d b&e=f#x@!a# @b x&y&z#'), array( + new ParsedShortcode(new Shortcode('a', array('b' => 'e=f'), 'x', 'c=d'), '@a&c=d b&e=f#x@!a#', 0), + )); + } + } + private function assertShortcodes(array $actual, array $expected) { $count = count($actual);