Skip to content

Commit a14e57e

Browse files
author
Jérémy Derussé
committed
Escape parameter on generated response
1 parent 51295a4 commit a14e57e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

HttpCache/Esi.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ private function handleEsiIncludeTag($attributes)
236236
throw new \RuntimeException('Unable to process an ESI tag without a "src" attribute.');
237237
}
238238

239-
return sprintf('<?php echo $this->esi->handle($this, \'%s\', \'%s\', %s) ?>'."\n",
240-
$options['src'],
241-
isset($options['alt']) ? $options['alt'] : null,
239+
return sprintf('<?php echo $this->esi->handle($this, %s, %s, %s) ?>'."\n",
240+
var_export($options['src'], true),
241+
var_export(isset($options['alt']) ? $options['alt'] : '', true),
242242
isset($options['onerror']) && 'continue' == $options['onerror'] ? 'true' : 'false'
243243
);
244244
}

Tests/HttpCache/EsiTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ public function testProcess()
110110
$this->assertEquals('foo <?php echo $this->esi->handle($this, \'...\', \'alt\', true) ?>'."\n", $response->getContent());
111111
$this->assertEquals('ESI', $response->headers->get('x-body-eval'));
112112

113+
$response = new Response('foo <esi:comment text="some comment" /><esi:include src="foo\'" alt="bar\'" onerror="continue" />');
114+
$esi->process($request, $response);
115+
116+
$this->assertEquals("foo <?php echo \$this->esi->handle(\$this, 'foo\\'', 'bar\\'', true) ?>"."\n", $response->getContent());
117+
113118
$response = new Response('foo <esi:include src="..." />');
114119
$esi->process($request, $response);
115120

0 commit comments

Comments
 (0)