Skip to content

Commit d4236ca

Browse files
committed
merged branch fabpot/hinclude-signer (PR #8960)
This PR was merged into the 2.2 branch. Discussion ---------- [HttpKernel] fix HInclude src (closes #8951) | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #8951 | License | MIT | Doc PR | n/a fixes a regression introduced in #8879 Commits ------- 49f5027 [HttpKernel] fixer HInclude src (closes #8951)
2 parents eb6b3b0 + 49f5027 commit d4236ca

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ public function render($uri, Request $request, array $options = array())
8080
throw new \LogicException('You must use a proper URI when using the Hinclude rendering strategy or set a URL signer.');
8181
}
8282

83-
$uri = $this->signer->sign($this->generateFragmentUri($uri, $request));
83+
// we need to sign the absolute URI, but want to return the path only.
84+
$uri = str_replace($request->getSchemeAndHttpHost(), '', $this->signer->sign($this->generateFragmentUri($uri, $request, true)));
8485
}
8586

8687
// We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content.

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="https://github.com/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dmain_controller&amp;_hash=5RZ1IkwF487EaXt6buHka73CCtQ%3D"></hx:include>', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent());
41+
$this->assertEquals('<hx:include src="https://github.com/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dmain_controller&amp;_hash=g4b3vtCnhkZBFKrciEFwG7fucVo%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)