Skip to content

Commit 8f3a65f

Browse files
authored
Merge pull request #75 from thunderer/fix-falsy-parameter-value
Fixed skipping shortcodes in RegularParser
2 parents ccf16e8 + 7e26f78 commit 8f3a65f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Diff for: src/Parser/RegularParser.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ private function value()
200200
return $this->match(self::TOKEN_DELIMITER, false) ? $value : false;
201201
}
202202

203-
if($tmp = $this->match(self::TOKEN_STRING, false)) {
203+
if('' !== $tmp = $this->match(self::TOKEN_STRING, false)) {
204204
$value .= $tmp;
205-
while($tmp = $this->match(self::TOKEN_STRING, false)) {
205+
while('' !== $tmp = $this->match(self::TOKEN_STRING, false)) {
206206
$value .= $tmp;
207207
}
208208

Diff for: tests/ParserTest.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ public function provideShortcodes()
225225
new ParsedShortcode(new Shortcode('y', array(), ' ] [] [ [z] [/#] [/z] [ [] ] [/] ', null), '[y] ] [] [ [z] [/#] [/z] [ [] ] [/] [/y]', 27),
226226
new ParsedShortcode(new Shortcode('z', array(), ' [ [/ [/] /] ] ', null), '[z] [ [/ [/] /] ] [/z]', 70),
227227
)),
228+
// falsy string values
229+
array($s, '[a=0 b=0]0[/a]', array(
230+
new ParsedShortcode(new Shortcode('a', array('b' => '0'), '0', '0'), '[a=0 b=0]0[/a]', 0),
231+
)),
228232
);
229233

230234
/**
@@ -239,7 +243,7 @@ public function provideShortcodes()
239243
*
240244
* Tests cases from array above with identifiers in the array below must be skipped.
241245
*/
242-
$wordpressSkip = array(3, 6, 16, 21, 22, 23, 25, 32, 33, 34, 46, 47, 49);
246+
$wordpressSkip = array(3, 6, 16, 21, 22, 23, 25, 32, 33, 34, 46, 47, 49, 51);
243247
$result = array();
244248
foreach($tests as $key => $test) {
245249
$syntax = array_shift($test);

0 commit comments

Comments
 (0)