Skip to content

Commit

Permalink
Escape parameter on generated response
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérémy Derussé committed Sep 3, 2014
1 parent 1033dc5 commit b044c45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Symfony/Component/HttpKernel/HttpCache/Esi.php
Expand Up @@ -236,9 +236,9 @@ private function handleEsiIncludeTag($attributes)
throw new \RuntimeException('Unable to process an ESI tag without a "src" attribute.');
}

return sprintf('<?php echo $this->esi->handle($this, \'%s\', \'%s\', %s) ?>'."\n",
$options['src'],
isset($options['alt']) ? $options['alt'] : null,
return sprintf('<?php echo $this->esi->handle($this, %s, %s, %s) ?>'."\n",
var_export($options['src'], true),
var_export(isset($options['alt']) ? $options['alt'] : '', true),
isset($options['onerror']) && 'continue' == $options['onerror'] ? 'true' : 'false'
);
}
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php
Expand Up @@ -110,6 +110,11 @@ public function testProcess()
$this->assertEquals('foo <?php echo $this->esi->handle($this, \'...\', \'alt\', true) ?>'."\n", $response->getContent());
$this->assertEquals('ESI', $response->headers->get('x-body-eval'));

$response = new Response('foo <esi:comment text="some comment" /><esi:include src="foo\'" alt="bar\'" onerror="continue" />');
$esi->process($request, $response);

$this->assertEquals("foo <?php echo \$this->esi->handle(\$this, 'foo\\'', 'bar\\'', true) ?>"."\n", $response->getContent());

$response = new Response('foo <esi:include src="..." />');
$esi->process($request, $response);

Expand Down

0 comments on commit b044c45

Please sign in to comment.