mirror of
https://github.com/Mibew/handlebars.php.git
synced 2025-05-03 18:43:07 +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
|
* @param boolean $strict strict search? if not found then throw exception
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException in strict mode and variable not found
|
* @throws \InvalidArgumentException in strict mode and variable not found
|
||||||
|
* @throws \RuntimeException if supplied argument is a malformed quoted string
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function get($variableName, $strict = false)
|
public function get($variableName, $strict = false)
|
||||||
@ -225,7 +226,11 @@ class Context
|
|||||||
} elseif ($variableName == '@key') {
|
} elseif ($variableName == '@key') {
|
||||||
$current = $this->lastKey();
|
$current = $this->lastKey();
|
||||||
} elseif ($variableName[0] == "'" || $variableName[0] == '"') {
|
} 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 {
|
} else {
|
||||||
$chunks = explode('.', $variableName);
|
$chunks = explode('.', $variableName);
|
||||||
foreach ($chunks as $chunk) {
|
foreach ($chunks as $chunk) {
|
||||||
|
Loading…
Reference in New Issue
Block a user