Skip to content

Commit

Permalink
more quoting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
robocoder committed Dec 4, 2015
1 parent c727c14 commit 70e80a5
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1676,22 +1676,28 @@ protected function string(&$out)
$content = array();
$oldWhite = $this->eatWhiteDefault;
$this->eatWhiteDefault = false;
$hasInterpolation = false;

while ($this->matchString($m, $delim)) {
$content[] = $m[1];
if ($m[1] !== '') {
$content[] = $m[1];
}

if ($m[2] === '#{') {
$this->count -= strlen($m[2]);

if ($this->interpolation($inter, false)) {
$content[] = $inter;
$hasInterpolation = true;
} else {
$this->count += strlen($m[2]);
$content[] = '#{'; // ignore it
}
} elseif ($m[2] === '\\') {
if ($this->literal($delim, false)) {
$content[] = $delim === '"' ? $m[2] . $delim : $delim;
if ($this->literal('"', false)) {
$content[] = $m[2] . '"';
} elseif ($this->literal("'", false)) {
$content[] = $m[2] . "'";
} else {
$content[] = $m[2];
}
Expand All @@ -1704,6 +1710,18 @@ protected function string(&$out)
$this->eatWhiteDefault = $oldWhite;

if ($this->literal($delim)) {
if ($hasInterpolation) {
$delim = '"';

foreach ($content as &$string) {
if ($string === "\\'") {
$string = "'";
} elseif ($string === '\\"') {
$string = '"';
}
}
}

$out = array(Type::T_STRING, $delim, $content);

return true;
Expand Down Expand Up @@ -2394,9 +2412,9 @@ private function extractLineNumbers($buffer)

$this->sourcePositions[] = strlen($buffer);

if (substr($buffer, -1) !== "\n") {
if (substr($buffer, -1) !== "\n") {
$this->sourcePositions[] = strlen($buffer) + 1;
}
}
}

/**
Expand Down

0 comments on commit 70e80a5

Please sign in to comment.