mirror of
https://github.com/Mibew/handlebars.php.git
synced 2024-11-15 08:44:12 +03:00
Fixed edge case in Context::get where trim was eating trailing escaped quote in a quoted literal string that ends with an escaped quote
This commit is contained in:
parent
da1cf77c58
commit
78974dee1b
@ -184,6 +184,7 @@ class Context
|
||||
* @param boolean $strict strict search? if not found then throw exception
|
||||
*
|
||||
* @throws \InvalidArgumentException in strict mode and variable not found
|
||||
* @throws \RuntimeException if supplied argument is a malformed quoted string
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($variableName, $strict = false)
|
||||
@ -225,7 +226,11 @@ class Context
|
||||
} elseif ($variableName == '@key') {
|
||||
$current = $this->lastKey();
|
||||
} elseif ($variableName[0] == "'" || $variableName[0] == '"') {
|
||||
$current = trim($variableName, '"\'');
|
||||
if ($variableName[0] == substr($variableName, -1) && strlen($variableName) > 2){
|
||||
$current = substr($variableName, 1, strlen($variableName) -2);
|
||||
} else {
|
||||
throw new \RuntimeException("Malformed string: ".$variableName);
|
||||
}
|
||||
} else {
|
||||
$chunks = explode('.', $variableName);
|
||||
foreach ($chunks as $chunk) {
|
||||
|
Loading…
Reference in New Issue
Block a user