@@ -390,16 +390,16 @@ method might be vulnerable to some of these attacks because it depends on
390390the configuration of your web server. One simple solution to avoid these
391391attacks is to whitelist the hosts that your Symfony application can respond
392392to. That's the purpose of this ``trusted_hosts `` option. If the incoming
393- request's hostname doesn't match one in this list, the application won't
394- respond and the user will receive a 400 response.
393+ request's hostname doesn't match one of the regular expressions in this list,
394+ the application won't respond and the user will receive a 400 response.
395395
396396.. configuration-block ::
397397
398398 .. code-block :: yaml
399399
400400 # app/config/config.yml
401401 framework :
402- trusted_hosts : ['example.com', 'example.org']
402+ trusted_hosts : ['^ example\ .com$ ', '^ example\ .org$ ']
403403
404404 .. code-block :: xml
405405
@@ -413,8 +413,8 @@ respond and the user will receive a 400 response.
413413 http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
414414
415415 <framework : config >
416- <framework : trusted-host >example.com</framework : trusted-host >
417- <framework : trusted-host >example.org</framework : trusted-host >
416+ <framework : trusted-host >^ example\ .com$ </framework : trusted-host >
417+ <framework : trusted-host >^ example\ .org$ </framework : trusted-host >
418418 <!-- ... -->
419419 </framework : config >
420420 </container >
@@ -423,17 +423,17 @@ respond and the user will receive a 400 response.
423423
424424 // app/config/config.php
425425 $container->loadFromExtension('framework', array(
426- 'trusted_hosts' => array('example.com', 'example.org'),
426+ 'trusted_hosts' => array('^ example\ .com$ ', '^ example\ .org$ '),
427427 ));
428428
429- Hosts can also be configured using regular expressions (e.g. `` ^(.+\.)?example.com$ ``),
430- which make it easier to respond to any subdomain .
429+ Hosts can also be configured to respond to any subdomain, via
430+ `` ^(.+\.)?example\.com$ `` for instance .
431431
432432In addition, you can also set the trusted hosts in the front controller
433433using the ``Request::setTrustedHosts() `` method::
434434
435435 // web/app.php
436- Request::setTrustedHosts(array('^(.+\.)?example.com$', '^(.+\.)?example.org$'));
436+ Request::setTrustedHosts(array('^(.+\.)?example\ .com$', '^(.+\.)?example\ .org$'));
437437
438438The default value for this option is an empty array, meaning that the application
439439can respond to any given host.
0 commit comments