FIX: template parser erroring on strings partially matching true/false/null

This commit is contained in:
Loz Calver 2018-10-05 12:47:04 +01:00 committed by Guy Sartorelli
parent d6e8229352
commit 3a6c48cddb
No known key found for this signature in database
GPG Key ID: F313E3B9504D496A
3 changed files with 12 additions and 9 deletions

View File

@ -418,11 +418,11 @@ class SSTemplateParser extends Parser implements TemplateParser
# Null
Null: / null /i
Null: / (null)\b /i
# Booleans
Boolean: / (true|false) /i
Boolean: / (true|false)\b /i
# Integers and floats

View File

@ -1217,11 +1217,11 @@ class SSTemplateParser extends Parser implements TemplateParser
}
/* Null: / null /i */
/* Null: / (null)\b /i */
protected $match_Null_typestack = array('Null');
function match_Null ($stack = array()) {
$matchrule = "Null"; $result = $this->construct($matchrule, $matchrule, null);
if (( $subres = $this->rx( '/ null /i' ) ) !== FALSE) {
if (( $subres = $this->rx( '/ (null)\b /i' ) ) !== FALSE) {
$result["text"] .= $subres;
return $this->finalise($result);
}
@ -1229,11 +1229,11 @@ class SSTemplateParser extends Parser implements TemplateParser
}
/* Boolean: / (true|false) /i */
/* Boolean: / (true|false)\b /i */
protected $match_Boolean_typestack = array('Boolean');
function match_Boolean ($stack = array()) {
$matchrule = "Boolean"; $result = $this->construct($matchrule, $matchrule, null);
if (( $subres = $this->rx( '/ (true|false) /i' ) ) !== FALSE) {
if (( $subres = $this->rx( '/ (true|false)\b /i' ) ) !== FALSE) {
$result["text"] .= $subres;
return $this->finalise($result);
}

View File

@ -724,9 +724,12 @@ after'
['boolean:1', 'TRUE'],
['boolean:', 'false'],
['boolean:', 'FALSE'],
// Strings which loosely look like booleans
['string:truthy', 'truthy'],
['string:falsy', 'falsy'],
// Strings which may look like booleans/null to the parser
['string:nullish', 'nullish'],
['string:notnull', 'notnull'],
['string:truethy', 'truethy'],
['string:untrue', 'untrue'],
['string:falsey', 'falsey'],
// Integers
['integer:0', '0'],
['integer:1', '1'],