8000 [HttpKernel] hinclude fragment renderer must escape URIs properly to … · stloyd/symfony@54d7d25 · GitHub
[go: up one dir, main page]

Skip to content

Commit 54d7d25

Browse files
committed
[HttpKernel] hinclude fragment renderer must escape URIs properly to return valid html
1 parent 83fc5ed commit 54d7d25

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public function render($uri, Request $request, array $options = array())
6464
$uri = $this->signer->sign($this->generateFragmentUri($uri, $request));
6565
}
6666

67+
// We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content.
68+
$uri = str_replace('&', '&', $uri);
69+
6770
$template = isset($options['default']) ? $options['default'] : $this->globalDefaultTemplate;
6871
if (null !== $this->templating && $template && $this->templateExists($template)) {
6972
$content = $this->templating->render($template);

src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testRenderWithControllerAndSigner()
3838
{
3939
$strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo'));
4040

41-
$this->assertEquals('<hx:include src="http://localhost/_fragment?_path=_format%3Dhtml%26_controller%3Dmain_controller&_hash=VI25qJj8J0qveB3bGKPhsJtexKg%3D"></hx:include>', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent());
41+
$this->assertEquals('<hx:include src="http://localhost/_fragment?_path=_format%3Dhtml%26_controller%3Dmain_controller&amp;_hash=VI25qJj8J0qveB3bGKPhsJtexKg%3D"></hx:include>', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent());
4242
}
4343

4444
public function testRenderWithUri()

0 commit comments

Comments
 (0)
0