@@ -882,19 +882,16 @@ matter), Symfony2 uses the standard ``render`` helper to configure ESI tags:
882
882
883
883
.. code-block :: php
884
884
885
- <?php echo $view['actions']->render('...:news', array('max' => 5), array('standalone' => true)) ?>
885
+ <?php echo $view['actions']->render(
886
+ $view['router']->generate('latest_news', array('max' => 5), true),
887
+ array(),
888
+ array('standalone' => true)
889
+ ) ?>
886
890
887
- .. note ::
888
-
889
- Since Symfony 2.0.20, the Twig ``render `` tag now takes an absolute url
890
- instead of a controller logical path. This fixes an important security
891
- issue (`CVE-2012-6431 `_) reported on the official blog. If your application
892
- uses an older version of Symfony or still uses the previous ``render `` tag
893
- syntax, we highly advise you to upgrade as soon as possible.
891
+ .. include :: /book/_security-2012-6431.rst.inc
894
892
895
- The ``render `` tag takes the absolute url of the embedded action. The latter has
896
- to be defined somewhere in one of the application's or bundles' routing
897
- configuration files:
893
+ The ``render `` tag takes the absolute url to the embedded action. This means
894
+ that you need to define a new route to the controller that you're embedding:
898
895
899
896
.. code-block :: yaml
900
897
@@ -904,18 +901,22 @@ configuration files:
904
901
defaults : { _controller: AcmeNewsBundle:News:news }
905
902
requirements : { max: \d+ }
906
903
904
+ .. caution ::
905
+
906
+ Unless you want this URL to be accessible to the outside world, you
907
+ should use Symfony's firewall to secure it (by allowing access to your
908
+ reverse proxy's IP range). See the :ref: `Securing by IP<book-security-securing-ip> `
909
+ section of the :doc: `Security Chapter </book/security >` for more information
910
+ on how to do this.
911
+
907
912
.. tip ::
908
913
909
- The best practice is to mount all your ESI urls on a single prefix of your
910
- choice. This has two main advantages. First, it eases the management of
911
- ESI urls as you can easily identify the routes used to handle ESIs.
912
- Secondly, it eases security management. Since an ESI route allows an action
913
- to be accessed via a URL, you might want to protect it by using the Symfony2
914
- firewall feature (by allowing access to your reverse proxy's IP range).
915
- Securing all urls starting with the same prefix is easier than securing each
916
- single url. See the :ref: `Securing by IP<book-security-securing-ip> ` section
917
- of the :doc: `Security Chapter </book/security >` for more information on how
918
- to do this.
914
+ The best practice is to mount all your ESI urls on a single prefix (e.g.
915
+ ``/esi ``) of your choice. This has two main advantages. First, it eases
916
+ the management of ESI urls as you can easily identify the routes used for ESI.
917
+ Second, it eases security management since securing all urls starting
918
+ with the same prefix is easier than securing each individual url. See
919
+ the above note for more details on securing ESI URLs.
919
920
920
921
By setting ``standalone `` to ``true `` in the ``render `` Twig tag, you tell
921
922
Symfony2 that the action should be rendered as an ESI tag. You might be
@@ -1058,4 +1059,3 @@ Learn more from the Cookbook
1058
1059
.. _`P4 - Conditional Requests` : http://tools.ietf.org/html/draft-ietf-httpbis-p4-conditional-12
1059
1060
.. _`P6 - Caching: Browser and intermediary caches` : http://tools.ietf.org/html/draft-ietf-httpbis-p6-cache-12
1060
1061
.. _`ESI` : http://www.w3.org/TR/esi-lang
1061
- .. _`CVE-2012-6431` : http://symfony.com/blog/security-release-symfony-2-0-20-and-2-1-5-released
0 commit comments