Merge branch '2.2' into 2.3
* 2.2: [HttpFoundation] fixed regression in the way the request format is handled for duplicated requests (closes #8917) [HttpKernel] fixer HInclude src (closes #8951) Fixed escaping of service identifiers in configuration
This commit is contained in:
commit
a010ed4721
@ -82,7 +82,13 @@ class Configuration implements ConfigurationInterface
|
|||||||
->prototype('array')
|
->prototype('array')
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
->ifTrue(function($v){ return is_string($v) && 0 === strpos($v, '@'); })
|
->ifTrue(function($v){ return is_string($v) && 0 === strpos($v, '@'); })
|
||||||
->then(function($v){ return array('id' => substr($v, 1), 'type' => 'service'); })
|
->then(function($v){
|
||||||
|
if (0 === strpos($v, '@@')) {
|
||||||
|
return substr($v, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array('id' => substr($v, 1), 'type' => 'service');
|
||||||
|
})
|
||||||
->end()
|
->end()
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
->ifTrue(function($v){
|
->ifTrue(function($v){
|
||||||
|
@ -8,6 +8,7 @@ $container->loadFromExtension('twig', array(
|
|||||||
),
|
),
|
||||||
'globals' => array(
|
'globals' => array(
|
||||||
'foo' => '@bar',
|
'foo' => '@bar',
|
||||||
|
'baz' => '@@qux',
|
||||||
'pi' => 3.14,
|
'pi' => 3.14,
|
||||||
'bad' => array('key' => 'foo'),
|
'bad' => array('key' => 'foo'),
|
||||||
),
|
),
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
<twig:resource>MyBundle::form.html.twig</twig:resource>
|
<twig:resource>MyBundle::form.html.twig</twig:resource>
|
||||||
</twig:form>
|
</twig:form>
|
||||||
<twig:global key="foo" id="bar" type="service" />
|
<twig:global key="foo" id="bar" type="service" />
|
||||||
|
<twig:global key="baz">@@qux</twig:global>
|
||||||
<twig:global key="pi">3.14</twig:global>
|
<twig:global key="pi">3.14</twig:global>
|
||||||
<twig:path>path1</twig:path>
|
<twig:path>path1</twig:path>
|
||||||
<twig:path>path2</twig:path>
|
<twig:path>path2</twig:path>
|
||||||
|
@ -4,6 +4,7 @@ twig:
|
|||||||
- MyBundle::form.html.twig
|
- MyBundle::form.html.twig
|
||||||
globals:
|
globals:
|
||||||
foo: "@bar"
|
foo: "@bar"
|
||||||
|
baz: "@@qux"
|
||||||
pi: 3.14
|
pi: 3.14
|
||||||
bad: {key: foo}
|
bad: {key: foo}
|
||||||
auto_reload: true
|
auto_reload: true
|
||||||
|
@ -63,13 +63,15 @@ class TwigExtensionTest extends TestCase
|
|||||||
$this->assertEquals(new Reference('templating.globals'), $calls[0][1][1]);
|
$this->assertEquals(new Reference('templating.globals'), $calls[0][1][1]);
|
||||||
$this->assertEquals('foo', $calls[1][1][0], '->load() registers services as Twig globals');
|
$this->assertEquals('foo', $calls[1][1][0], '->load() registers services as Twig globals');
|
||||||
$this->assertEquals(new Reference('bar'), $calls[1][1][1], '->load() registers services as Twig globals');
|
$this->assertEquals(new Reference('bar'), $calls[1][1][1], '->load() registers services as Twig globals');
|
||||||
$this->assertEquals('pi', $calls[2][1][0], '->load() registers variables as Twig globals');
|
$this->assertEquals('baz', $calls[2][1][0], '->load() registers variables as Twig globals');
|
||||||
$this->assertEquals(3.14, $calls[2][1][1], '->load() registers variables as Twig globals');
|
$this->assertEquals('@qux', $calls[2][1][1], '->load() allows escaping of service identifiers');
|
||||||
|
$this->assertEquals('pi', $calls[3][1][0], '->load() registers variables as Twig globals');
|
||||||
|
$this->assertEquals(3.14, $calls[3][1][1], '->load() registers variables as Twig globals');
|
||||||
|
|
||||||
// Yaml and Php specific configs
|
// Yaml and Php specific configs
|
||||||
if (in_array($format, array('yml', 'php'))) {
|
if (in_array($format, array('yml', 'php'))) {
|
||||||
$this->assertEquals('bad', $calls[3][1][0], '->load() registers variables as Twig globals');
|
$this->assertEquals('bad', $calls[4][1][0], '->load() registers variables as Twig globals');
|
||||||
$this->assertEquals(array('key' => 'foo'), $calls[3][1][1], '->load() registers variables as Twig globals');
|
$this->assertEquals(array('key' => 'foo'), $calls[4][1][1], '->load() registers variables as Twig globals');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Twig options
|
// Twig options
|
||||||
|
@ -405,7 +405,8 @@ class Request
|
|||||||
$dup->format = null;
|
$dup->format = null;
|
||||||
|
|
||||||
if (!$dup->get('_format')) {
|
if (!$dup->get('_format')) {
|
||||||
$dup->setRequestFormat($this->getRequestFormat());
|
// we set the request format to null if the current request is not known
|
||||||
|
$dup->setRequestFormat($this->getRequestFormat(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $dup;
|
return $dup;
|
||||||
|
@ -91,7 +91,8 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
|||||||
throw new \LogicException('You must use a proper URI when using the Hinclude rendering strategy or set a URL signer.');
|
throw new \LogicException('You must use a proper URI when using the Hinclude rendering strategy or set a URL signer.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$uri = $this->signer->sign($this->generateFragmentUri($uri, $request));
|
// we need to sign the absolute URI, but want to return the path only.
|
||||||
|
$uri = str_replace($request->getSchemeAndHttpHost(), '', $this->signer->sign($this->generateFragmentUri($uri, $request, true)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content.
|
// We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content.
|
||||||
|
@ -38,7 +38,7 @@ class HIncludeFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo'));
|
$strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo'));
|
||||||
|
|
||||||
$this->assertEquals('<hx:include src="/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dmain_controller&_hash=5RZ1IkwF487EaXt6buHka73CCtQ%3D"></hx:include>', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent());
|
$this->assertEquals('<hx:include src="/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dmain_controller&_hash=g4b3vtCnhkZBFKrciEFwG7fucVo%3D"></hx:include>', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRenderWithUri()
|
public function testRenderWithUri()
|
||||||
|
Reference in New Issue
Block a user