Permalink
Browse files

Merge branch '2.2'

* 2.2:
  Defined stable version point of Doctrine.
  [HttpFoundation] Remove Cache-Control when using https download via IE<9 (fixes #6750)
  Update composer.json
  [Form] Fixed TimeType not to render a "size" attribute in select tags
  [Form] Added test for "label" option to accept the value "0"
  Expanded fault-tolerance for unusual cookie dates
  Fix docblock type
  [Form] Fixed "label" option to accept the value "0"
  Added greek translation
  merged branch jfcixmedia/2.1 (PR #5838)
  added a note about a BC break for the path info of sub-request (closes #7138)
  [DomCrawler] lowered parsed protocol string (fixes #6986)
  [FrameworkBundle] Fix a BC for Hinclude global template
  [HttpKernel] fixed locale management when exiting sub-requests
  fixed HInclude renderer (closes #7113)
  Removed some leaking deprecation warning in the Form component
  [HttpKernel] hinclude fragment renderer must escape URIs properly to return valid html

Conflicts:
	src/Symfony/Bundle/FrameworkBundle/composer.json
	src/Symfony/Component/Security/composer.json
  • Loading branch information...
2 parents 1c783f6 + 825dc17 commit fb7004baab20d1c861c47545b2ba7bccfc830e18 @fabpot fabpot committed Feb 23, 2013
Showing with 238 additions and 55 deletions.
  1. +21 −21 src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
  2. +1 −1 src/Symfony/Bridge/Twig/Extension/FormExtension.php
  3. +2 −1 src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
  4. +1 −1 src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
  5. +3 −1 src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php
  6. +4 −3 src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/time_widget.html.php
  7. +30 −0 src/Symfony/Bundle/FrameworkBundle/Tests/Fragments/ContainerAwareHIncludeFragmentRendererTest.php
  8. +1 −1 src/Symfony/Bundle/FrameworkBundle/composer.json
  9. +7 −0 src/Symfony/Component/BrowserKit/Cookie.php
  10. +4 −1 src/Symfony/Component/BrowserKit/Tests/CookieTest.php
  11. +1 −1 src/Symfony/Component/DomCrawler/Link.php
  12. +2 −0 src/Symfony/Component/Form/ResolvedFormType.php
  13. +19 −0 src/Symfony/Component/Form/Resources/translations/validators.el.xlf
  14. +6 −5 src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
  15. +13 −0 src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php
  16. +2 −2 src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php
  17. +1 −1 src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php
  18. +0 −7 src/Symfony/Component/Form/Tests/FormIntegrationTestCase.php
  19. +10 −0 src/Symfony/Component/HttpFoundation/Response.php
  20. +69 −0 src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
  21. +1 −0 src/Symfony/Component/HttpKernel/CHANGELOG.md
  22. +25 −7 src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php
  23. +13 −0 src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php
  24. +1 −1 src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php
  25. +1 −1 src/Symfony/Component/Security/composer.json
View
42 src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
@@ -209,7 +209,7 @@ public function testSetDataSingleNull()
$field->setData(null);
$this->assertNull($field->getData());
- $this->assertSame('', $field->getClientData());
+ $this->assertSame('', $field->getViewData());
}
public function testSetDataMultipleExpandedNull()
@@ -223,7 +223,7 @@ public function testSetDataMultipleExpandedNull()
$field->setData(null);
$this->assertNull($field->getData());
- $this->assertSame(array(), $field->getClientData());
+ $this->assertSame(array(), $field->getViewData());
}
public function testSetDataMultipleNonExpandedNull()
@@ -237,7 +237,7 @@ public function testSetDataMultipleNonExpandedNull()
$field->setData(null);
$this->assertNull($field->getData());
- $this->assertSame(array(), $field->getClientData());
+ $this->assertSame(array(), $field->getViewData());
}
public function testSubmitSingleExpandedNull()
@@ -251,7 +251,7 @@ public function testSubmitSingleExpandedNull()
$field->bind(null);
$this->assertNull($field->getData());
- $this->assertSame(array(), $field->getClientData());
+ $this->assertSame(array(), $field->getViewData());
}
public function testSubmitSingleNonExpandedNull()
@@ -265,7 +265,7 @@ public function testSubmitSingleNonExpandedNull()
$field->bind(null);
$this->assertNull($field->getData());
- $this->assertSame('', $field->getClientData());
+ $this->assertSame('', $field->getViewData());
}
public function testSubmitMultipleNull()
@@ -278,7 +278,7 @@ public function testSubmitMultipleNull()
$field->bind(null);
$this->assertEquals(new ArrayCollection(), $field->getData());
- $this->assertSame(array(), $field->getClientData());
+ $this->assertSame(array(), $field->getViewData());
}
public function testSubmitSingleNonExpandedSingleIdentifier()
@@ -300,7 +300,7 @@ public function testSubmitSingleNonExpandedSingleIdentifier()
$this->assertTrue($field->isSynchronized());
$this->assertSame($entity2, $field->getData());
- $this->assertSame('2', $field->getClientData());
+ $this->assertSame('2', $field->getViewData());
}
public function testSubmitSingleNonExpandedCompositeIdentifier()
@@ -323,7 +323,7 @@ public function testSubmitSingleNonExpandedCompositeIdentifier()
$this->assertTrue($field->isSynchronized());
$this->assertSame($entity2, $field->getData());
- $this->assertSame('1', $field->getClientData());
+ $this->assertSame('1', $field->getViewData());
}
public function testSubmitMultipleNonExpandedSingleIdentifier()
@@ -348,7 +348,7 @@ public function testSubmitMultipleNonExpandedSingleIdentifier()
$this->assertTrue($field->isSynchronized());
$this->assertEquals($expected, $field->getData());
- $this->assertSame(array('1', '3'), $field->getClientData());
+ $this->assertSame(array('1', '3'), $field->getViewData());
}
public function testSubmitMultipleNonExpandedSingleIdentifierForExistingData()
@@ -379,7 +379,7 @@ public function testSubmitMultipleNonExpandedSingleIdentifierForExistingData()
$this->assertEquals($expected, $field->getData());
// same object still, useful if it is a PersistentCollection
$this->assertSame($existing, $field->getData());
- $this->assertSame(array('1', '3'), $field->getClientData());
+ $this->assertSame(array('1', '3'), $field->getViewData());
}
public function testSubmitMultipleNonExpandedCompositeIdentifier()
@@ -405,7 +405,7 @@ public function testSubmitMultipleNonExpandedCompositeIdentifier()
$this->assertTrue($field->isSynchronized());
$this->assertEquals($expected, $field->getData());
- $this->assertSame(array('0', '2'), $field->getClientData());
+ $this->assertSame(array('0', '2'), $field->getViewData());
}
public function testSubmitMultipleNonExpandedCompositeIdentifierExistingData()
@@ -436,7 +436,7 @@ public function testSubmitMultipleNonExpandedCompositeIdentifierExistingData()
$this->assertEquals($expected, $field->getData());
// same object still, useful if it is a PersistentCollection
$this->assertSame($existing, $field->getData());
- $this->assertSame(array('0', '2'), $field->getClientData());
+ $this->assertSame(array('0', '2'), $field->getViewData());
}
public function testSubmitSingleExpanded()
@@ -460,8 +460,8 @@ public function testSubmitSingleExpanded()
$this->assertSame($entity2, $field->getData());
$this->assertFalse($field['1']->getData());
$this->assertTrue($field['2']->getData());
- $this->assertNull($field['1']->getClientData());
- $this->assertSame('2', $field['2']->getClientData());
+ $this->assertNull($field['1']->getViewData());
+ $this->assertSame('2', $field['2']->getViewData());
}
public function testSubmitMultipleExpanded()
@@ -489,9 +489,9 @@ public function testSubmitMultipleExpanded()
$this->assertTrue($field['1']->getData());
$this->assertFalse($field['2']->getData());
$this->assertTrue($field['3']->getData());
- $this->assertSame('1', $field['1']->getClientData());
- $this->assertNull($field['2']->getClientData());
- $this->assertSame('3', $field['3']->getClientData());
+ $this->assertSame('1', $field['1']->getViewData());
+ $this->assertNull($field['2']->getViewData());
+ $this->assertSame('3', $field['3']->getViewData());
}
public function testOverrideChoices()
@@ -515,7 +515,7 @@ public function testOverrideChoices()
$this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']);
$this->assertTrue($field->isSynchronized());
$this->assertSame($entity2, $field->getData());
- $this->assertSame('2', $field->getClientData());
+ $this->assertSame('2', $field->getViewData());
}
public function testGroupByChoices()
@@ -537,7 +537,7 @@ public function testGroupByChoices()
$field->bind('2');
- $this->assertSame('2', $field->getClientData());
+ $this->assertSame('2', $field->getViewData());
$this->assertEquals(array(
'Group1' => array(1 => new ChoiceView($item1, '1', 'Foo'), 2 => new ChoiceView($item2, '2', 'Bar')),
'Group2' => array(3 => new ChoiceView($item3, '3', 'Baz')),
@@ -716,7 +716,7 @@ public function testSubmitSingleStringIdentifier()
$this->assertTrue($field->isSynchronized());
$this->assertSame($entity1, $field->getData());
- $this->assertSame('foo', $field->getClientData());
+ $this->assertSame('foo', $field->getViewData());
}
public function testSubmitCompositeStringIdentifier()
@@ -738,7 +738,7 @@ public function testSubmitCompositeStringIdentifier()
$this->assertTrue($field->isSynchronized());
$this->assertSame($entity1, $field->getData());
- $this->assertSame('0', $field->getClientData());
+ $this->assertSame('0', $field->getViewData());
}
public function testGetManagerForClassIfNoEm()
View
2 src/Symfony/Bridge/Twig/Extension/FormExtension.php
@@ -27,7 +27,7 @@ class FormExtension extends \Twig_Extension
* This property is public so that it can be accessed directly from compiled
* templates without having to call a getter, which slightly decreases performance.
*
- * @var \Symfony\Component\Form\FormRendererInterface
+ * @var TwigRendererInterface
*/
public $renderer;
View
3 src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
@@ -147,8 +147,9 @@
{% if widget == 'single_text' %}
{{ block('form_widget_simple') }}
{% else %}
+ {% set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} %}
<div {{ block('widget_container_attributes') }}>
- {{ form_widget(form.hour, { 'attr': { 'size': '1' } }) }}{% if with_minutes %}:{{ form_widget(form.minute, { 'attr': { 'size': '1' } }) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second, { 'attr': { 'size': '1' } }) }}{% endif %}
+ {{ form_widget(form.hour, vars) }}{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %}
</div>
{% endif %}
{% endspaceless %}
View
2 src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@@ -365,7 +365,7 @@ private function registerTemplatingConfiguration(array $config, $ide, ContainerB
$container->setParameter('templating.helper.code.file_link_format', isset($links[$ide]) ? $links[$ide] : $ide);
$container->setParameter('templating.helper.form.resources', $config['form']['resources']);
- $container->setParameter('templating.hinclude.default_template', $config['hinclude_default_template']);
+ $container->setParameter('fragment.renderer.hinclude.global_template', $config['hinclude_default_template']);
if ($container->getParameter('kernel.debug')) {
$loader->load('templating_debug.xml');
View
4 src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php
@@ -40,7 +40,9 @@ public function __construct(ContainerInterface $container, UriSigner $signer = n
*/
public function render($uri, Request $request, array $options = array())
{
- if (!$this->templating) {
+ // setting the templating cannot be done in the constructor
+ // as it would lead to an infinite recursion in the service container
+ if (!$this->hasTemplating()) {
$this->setTemplating($this->container->get('templating'));
}
View
7 src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/time_widget.html.php
@@ -1,20 +1,21 @@
<?php if ($widget == 'single_text'): ?>
<?php echo $view['form']->block($form, 'form_widget_simple'); ?>
<?php else: ?>
+ <?php $vars = $widget == 'text' ? array('attr' => array('size' => 1)) : array() ?>
<div <?php echo $view['form']->block($form, 'widget_container_attributes') ?>>
<?php
// There should be no spaces between the colons and the widgets, that's why
// this block is written in a single PHP tag
- echo $view['form']->widget($form['hour'], array('attr' => array('size' => 1)));
+ echo $view['form']->widget($form['hour'], $vars);
if ($with_minutes) {
echo ':';
- echo $view['form']->widget($form['minute'], array('attr' => array('size' => 1)));
+ echo $view['form']->widget($form['minute'], $vars);
}
if ($with_seconds) {
echo ':';
- echo $view['form']->widget($form['second'], array('attr' => array('size' => 1)));
+ echo $view['form']->widget($form['second'], $vars);
}
?>
</div>
View
30 ...ony/Bundle/FrameworkBundle/Tests/Fragments/ContainerAwareHIncludeFragmentRendererTest.php
@@ -0,0 +1,30 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Bundle\FrameworkBundle\Tests\Fragment;
+
+use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
+use Symfony\Bundle\FrameworkBundle\Fragment\ContainerAwareHIncludeFragmentRenderer;
+use Symfony\Component\HttpFoundation\Request;
+
+class ContainerAwareHIncludeFragmentRendererTest extends TestCase
+{
+ public function testRender()
+ {
+ $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container->expects($this->once())
+ ->method('get')
+ ->will($this->returnValue($this->getMock('\Twig_Environment')))
+ ;
+ $renderer = new ContainerAwareHIncludeFragmentRenderer($container);
+ $renderer->render('/', Request::create('/'));
+ }
+}
View
2 src/Symfony/Bundle/FrameworkBundle/composer.json
@@ -26,7 +26,7 @@
"symfony/stopwatch": ">=2.2,<2.4-dev",
"symfony/templating": "~2.1",
"symfony/translation": ">=2.2,<2.4-dev",
- "doctrine/common": ">=2.2,<2.4-dev"
+ "doctrine/common": "~2.2"
},
"require-dev": {
"symfony/finder": "~2.0",
View
7 src/Symfony/Component/BrowserKit/Cookie.php
@@ -30,6 +30,8 @@ class Cookie
'D, d M Y H:i:s T',
'D, d-M-y H:i:s T',
'D, d-M-Y H:i:s T',
+ 'D, d-m-y H:i:s T',
+ 'D, d-m-Y H:i:s T',
'D M j G:i:s Y',
'D M d H:i:s Y T',
);
@@ -205,6 +207,11 @@ private static function parseDate($dateValue)
}
}
+ // attempt a fallback for unusual formatting
+ if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) {
+ return $date->getTimestamp();
+ }
+
throw new \InvalidArgumentException(sprintf('Could not parse date "%s".', $dateValue));
}
View
5 src/Symfony/Component/BrowserKit/Tests/CookieTest.php
@@ -56,9 +56,12 @@ public function getExpireCookieStrings()
return array(
array('foo=bar; expires=Fri, 31-Jul-2020 08:49:37 GMT'),
array('foo=bar; expires=Fri, 31 Jul 2020 08:49:37 GMT'),
+ array('foo=bar; expires=Fri, 31-07-2020 08:49:37 GMT'),
+ array('foo=bar; expires=Fri, 31-07-20 08:49:37 GMT'),
array('foo=bar; expires=Friday, 31-Jul-20 08:49:37 GMT'),
array('foo=bar; expires=Fri Jul 31 08:49:37 2020'),
array('foo=bar; expires=\'Fri Jul 31 08:49:37 2020\''),
+ array('foo=bar; expires=Friday July 31st 2020, 08:49:37 GMT'),
);
}
@@ -86,7 +89,7 @@ public function testFromStringThrowsAnExceptionIfCookieIsNotValid()
public function testFromStringThrowsAnExceptionIfCookieDateIsNotValid()
{
$this->setExpectedException('InvalidArgumentException');
- Cookie::FromString('foo=bar; expires=foo');
+ Cookie::FromString('foo=bar; expires=Flursday July 31st 2020, 08:49:37 GMT');
}
public function testFromStringThrowsAnExceptionIfUrlIsNotValid()
View
2 src/Symfony/Component/DomCrawler/Link.php
@@ -46,7 +46,7 @@ class Link
*/
public function __construct(\DOMNode $node, $currentUri, $method = 'GET')
{
- if (!in_array(substr($currentUri, 0, 4), array('http', 'file'))) {
+ if (!in_array(strtolower(substr($currentUri, 0, 4)), array('http', 'file'))) {
throw new \InvalidArgumentException(sprintf('Current URI must be an absolute URL ("%s").', $currentUri));
}
View
2 src/Symfony/Component/Form/ResolvedFormType.php
@@ -62,7 +62,9 @@ public function __construct(FormTypeInterface $innerType, array $typeExtensions
// BC
if ($innerType instanceof AbstractType) {
/* @var AbstractType $innerType */
+ set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
$innerType->setExtensions($typeExtensions);
+ restore_error_handler();
}
$this->innerType = $innerType;
View
19 src/Symfony/Component/Form/Resources/translations/validators.el.xlf
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
+ <file source-language="en" datatype="plaintext" original="file.ext">
+ <body>
+ <trans-unit id="28">
+ <source>This form should not contain extra fields.</source>
+ <target>Αυτή η φόρμα δεν πρέπει να περιέχει επιπλέον πεδία.</target>
+ </trans-unit>
+ <trans-unit id="29">
+ <source>The uploaded file was too large. Please try to upload a smaller file.</source>
+ <target>Το αρχείο είναι πολύ μεγάλο. Παρακαλούμε προσπαθήστε να ανεβάσετε ένα μικρότερο αρχείο.</target>
+ </trans-unit>
+ <trans-unit id="30">
+ <source>The CSRF token is invalid. Please try to resubmit the form.</source>
+ <target>Το CSRF token δεν είναι έγκυρο. Παρακαλούμε δοκιμάστε να υποβάλετε τη φόρμα ξανά.</target>
+ </trans-unit>
+ </body>
+ </file>
+</xliff>
View
11 src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
@@ -1533,11 +1533,11 @@ public function testTime()
[
./select
[@id="name_hour"]
- [@size="1"]
+ [not(@size)]
[./option[@value="4"][@selected="selected"]]
/following-sibling::select
[@id="name_minute"]
- [@size="1"]
+ [not(@size)]
[./option[@value="5"][@selected="selected"]]
]
[count(./select)=2]
@@ -1557,17 +1557,17 @@ public function testTimeWithSeconds()
[
./select
[@id="name_hour"]
- [@size="1"]
+ [not(@size)]
[./option[@value="4"][@selected="selected"]]
[count(./option)>23]
/following-sibling::select
[@id="name_minute"]
- [@size="1"]
+ [not(@size)]
[./option[@value="5"][@selected="selected"]]
[count(./option)>59]
/following-sibling::select
[@id="name_second"]
- [@size="1"]
+ [not(@size)]
[./option[@value="6"][@selected="selected"]]
[count(./option)>59]
]
@@ -1618,6 +1618,7 @@ public function testTimeSingleText()
[@type="time"]
[@name="name"]
[@value="04:05"]
+ [not(@size)]
'
);
}
View
13 src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php
@@ -601,9 +601,11 @@ public function testPropertyPathNullImpliesDefault()
// BC
public function testPropertyPathFalseImpliesDefaultNotMapped()
{
+ set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
$form = $this->factory->createNamed('name', 'form', null, array(
'property_path' => false,
));
+ restore_error_handler();
$this->assertEquals(new PropertyPath('name'), $form->getPropertyPath());
$this->assertFalse($form->getConfig()->getMapped());
@@ -661,4 +663,15 @@ public function testNormDataIsPassedToView()
$this->assertSame('foo', $view->vars['data']);
$this->assertSame('bar', $view->vars['value']);
}
+
+ // https://github.com/symfony/symfony/issues/6862
+ public function testPassZeroLabelToView()
+ {
+ $view = $this->factory->create('form', null, array(
+ 'label' => '0'
+ ))
+ ->createView();
+
+ $this->assertSame('0', $view->vars['label']);
+ }
}
View
4 src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php
@@ -42,7 +42,7 @@ public function testPassDifferentPatternsForDifferentCurrencies()
$view1 = $form1->createView();
$view2 = $form2->createView();
- $this->assertSame('{{ widget }} £', $view1->get('money_pattern'));
- $this->assertSame('{{ widget }} €', $view2->get('money_pattern'));
+ $this->assertSame('{{ widget }} £', $view1->vars['money_pattern']);
+ $this->assertSame('{{ widget }} €', $view2->vars['money_pattern']);
}
}
View
2 src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php
@@ -231,7 +231,7 @@ public function testSetDataWithoutMinutes()
$form->setData(new \DateTime('03:04:05 UTC'));
- $this->assertEquals(array('hour' => 3), $form->getClientData());
+ $this->assertEquals(array('hour' => 3), $form->getViewData());
}
public function testSetDataWithSeconds()
View
7 src/Symfony/Component/Form/Tests/FormIntegrationTestCase.php
@@ -32,13 +32,6 @@ protected function setUp()
$this->factory = Forms::createFormFactoryBuilder()
->addExtensions($this->getExtensions())
->getFormFactory();
-
- set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
- }
-
- protected function tearDown()
- {
- restore_error_handler();
}
protected function getExtensions()
View
10 src/Symfony/Component/HttpFoundation/Response.php
@@ -253,6 +253,16 @@ public function prepare(Request $request)
$this->headers->set('expires', -1);
}
+ /**
+ * Check if we need to remove Cache-Control for ssl encrypted downloads when using IE < 9
+ * @link http://support.microsoft.com/kb/323308
+ */
+ if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) {
+ if(intval(preg_replace("/(MSIE )(.*?);/", "$2", $match[0])) < 9) {
+ $this->headers->remove('Cache-Control');
+ }
+ }
+
return $this;
}
View
69 src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
@@ -326,6 +326,75 @@ public function testContentTypeCharset()
$this->assertEquals('text/css; charset=UTF-8', $response->headers->get('Content-Type'));
}
+ public function testNoCacheControlHeaderOnAttachmentUsingHTTPSAndMSIE()
+ {
+ // Check for HTTPS and IE 8
+ $request = new Request();
+ $request->server->set('HTTPS', true);
+ $request->server->set('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)');
+
+ $response = new Response();
+ $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
+ $response->prepare($request);
+
+ $this->assertFalse($response->headers->has('Cache-Control'));
+
+ // Check for IE 10 and HTTPS
+ $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)');
+
+ $response = new Response();
+ $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
+ $response->prepare($request);
+
+ $this->assertTrue($response->headers->has('Cache-Control'));
+
+ // Check for IE 9 and HTTPS
+ $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)');
+
+ $response = new Response();
+ $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
+ $response->prepare($request);
+
+ $this->assertTrue($response->headers->has('Cache-Control'));
+
+ // Check for IE 9 and HTTP
+ $request->server->set('HTTPS', false);
+
+ $response = new Response();
+ $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
+ $response->prepare($request);
+
+ $this->assertTrue($response->headers->has('Cache-Control'));
+
+ // Check for IE 8 and HTTP
+ $request->server->set('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)');
+
+ $response = new Response();
+ $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
+ $response->prepare($request);
+
+ $this->assertTrue($response->headers->has('Cache-Control'));
+
+ // Check for non-IE and HTTPS
+ $request->server->set('HTTPS', true);
+ $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.60 Safari/537.17');
+
+ $response = new Response();
+ $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
+ $response->prepare($request);
+
+ $this->assertTrue($response->headers->has('Cache-Control'));
+
+ // Check for non-IE and HTTP
+ $request->server->set('HTTPS', false);
+
+ $response = new Response();
+ $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
+ $response->prepare($request);
+
+ $this->assertTrue($response->headers->has('Cache-Control'));
+ }
+
public function testPrepareDoesNothingIfContentTypeIsSet()
{
$response = new Response('foo');
View
1 src/Symfony/Component/HttpKernel/CHANGELOG.md
@@ -4,6 +4,7 @@ CHANGELOG
2.2.0
-----
+ * [BC BREAK] the path info for sub-request is now always _fragment (or whatever you configured instead of the default)
* added Symfony\Component\HttpKernel\EventListener\FragmentListener
* added Symfony\Component\HttpKernel\UriSigner
* added Symfony\Component\HttpKernel\FragmentRenderer and rendering strategies (in Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface)
View
32 src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php
@@ -12,7 +12,9 @@
namespace Symfony\Component\HttpKernel\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
+use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
+use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\RequestContextAwareInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -25,33 +27,49 @@ class LocaleListener implements EventSubscriberInterface
{
private $router;
private $defaultLocale;
+ private $locales = array();
public function __construct($defaultLocale = 'en', RequestContextAwareInterface $router = null)
{
$this->defaultLocale = $defaultLocale;
$this->router = $router;
}
+ public function onKernelResponse(FilterResponseEvent $event)
+ {
+ array_shift($this->locales);
+
+ // setting back the locale to the previous value
+ $locale = isset($this->locales[0]) ? $this->locales[0] : $this->defaultLocale;
+ $request = $event->getRequest();
+ $this->setLocale($request, $locale);
+ }
+
public function onKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
$request->setDefaultLocale($this->defaultLocale);
+ $this->setLocale($request, $request->attributes->get('_locale', $this->defaultLocale));
- if ($locale = $request->attributes->get('_locale')) {
- $request->setLocale($locale);
- }
-
- if (null !== $this->router) {
- $this->router->getContext()->setParameter('_locale', $request->getLocale());
- }
+ array_unshift($this->locales, $request->getLocale());
}
public static function getSubscribedEvents()
{
return array(
// must be registered after the Router to have access to the _locale
KernelEvents::REQUEST => array(array('onKernelRequest', 16)),
+ KernelEvents::RESPONSE => 'onKernelResponse',
);
}
+
+ private function setLocale(Request $request, $locale)
+ {
+ $request->setLocale($locale);
+
+ if (null !== $this->router) {
+ $this->router->getContext()->setParameter('_locale', $request->getLocale());
+ }
+ }
}
View
13 src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php
@@ -57,6 +57,16 @@ public function setTemplating($templating)
}
/**
+ * Checks if a templating engine has been set.
+ *
+ * @return Boolean true if the templating engine has been set, false otherwise
+ */
+ public function hasTemplating()
+ {
+ return null !== $this->templating;
+ }
+
+ /**
* {@inheritdoc}
*
* Additional available options:
@@ -73,6 +83,9 @@ public function render($uri, Request $request, array $options = array())
$uri = $this->signer->sign($this->generateFragmentUri($uri, $request));
}
+ // We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content.
+ $uri = str_replace('&', '&amp;', $uri);
+
$template = isset($options['default']) ? $options['default'] : $this->globalDefaultTemplate;
if (null !== $this->templating && $template && $this->templateExists($template)) {
$content = $this->templating->render($template);
View
2 src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php
@@ -38,7 +38,7 @@ public function testRenderWithControllerAndSigner()
{
$strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo'));
- $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());
+ $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());
}
public function testRenderWithUri()
View
2 src/Symfony/Component/Security/composer.json
@@ -25,7 +25,7 @@
"symfony/form": "~2.0",
"symfony/routing": ">=2.2,<2.4-dev",
"symfony/validator": ">=2.2,<2.4-dev",
- "doctrine/common": ">=2.2,<2.4-dev",
+ "doctrine/common": "~2.2",
"doctrine/dbal": "~2.2",
"psr/log": "~1.0"
},

0 comments on commit fb7004b

Please sign in to comment.