Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merged 2.0

  • Loading branch information...
commit b1148e334f49cd6acdfeb0d7148c140681182a9b 2 parents 79a957b + c9e8749
@fabpot fabpot authored
View
4 src/Symfony/Component/Config/Definition/VariableNode.php
@@ -14,9 +14,9 @@
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
/**
- * This node represents a variable value in the config tree.
+ * This node represents a value of variable type in the config tree.
*
- * This node is intended for arbitrary variables.
+ * This node is intended for values of arbitrary type.
* Any PHP type is accepted as a value.
*
* @author Jeremy Mikola <jmikola@gmail.com>
View
20 src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php
@@ -139,7 +139,7 @@ public function resolve()
foreach ($this->parameters as $key => $value) {
try {
$value = $this->resolveValue($value);
- $parameters[$key] = is_string($value) ? str_replace('%%', '%', $value) : $value;
+ $parameters[$key] = $this->unescapeValue($value);
} catch (ParameterNotFoundException $e) {
$e->setSourceKey($key);
@@ -235,4 +235,22 @@ public function isResolved()
{
return $this->resolved;
}
+
+ private function unescapeValue($value)
+ {
+ if (is_string($value)) {
+ return str_replace('%%', '%', $value);
+ }
+
+ if (is_array($value)) {
+ $result = array();
+ foreach ($value as $k => $v) {
+ $result[$k] = $this->unescapeValue($v);
+ }
+
+ return $result;
+ }
+
+ return $value;
+ }
}
View
2  src/Symfony/Component/Form/Extension/Core/Type/MoneyType.php
@@ -100,7 +100,7 @@ static private function getPattern($currency)
// the regex also considers non-break spaces (0xC2 or 0xA0 in UTF-8)
- preg_match('/^([^\s\xc2\xa0]*)[\s\xc2\xa0]*123[,.]00[\s\xc2\xa0]*([^\s\xc2\xa0]*)$/', $pattern, $matches);
+ preg_match('/^([^\s\xc2\xa0]*)[\s\xc2\xa0]*123(?:[,.]0+)?[\s\xc2\xa0]*([^\s\xc2\xa0]*)$/u', $pattern, $matches);
if (!empty($matches[1])) {
self::$patterns[\Locale::getDefault()] = $matches[1].' {{ widget }}';
View
1  src/Symfony/Component/HttpKernel/HttpCache/Esi.php
@@ -154,6 +154,7 @@ public function process(Request $request, Response $response)
// we don't use a proper XML parser here as we can have ESI tags in a plain text response
$content = $response->getContent();
+ $content = str_replace(array('<?', '<%'), array('<?php echo "<?"; ?>', '<?php echo "<%"; ?>'), $content);
$content = preg_replace_callback('#<esi\:include\s+(.*?)\s*(?:/|</esi\:include)>#', array($this, 'handleEsiIncludeTag'), $content);
$content = preg_replace('#<esi\:comment[^>]*(?:/|</esi\:comment)>#', '', $content);
$content = preg_replace('#<esi\:remove>.*?</esi\:remove>#', '', $content);
View
27 tests/Symfony/Tests/Bridge/Doctrine/Form/ChoiceList/EntityChoiceListTest.php
@@ -47,6 +47,33 @@ protected function tearDown()
/**
* @expectedException Symfony\Component\Form\Exception\FormException
+ * @expectedMessage Entity "Symfony\Tests\Bridge\Doctrine\Fixtures\SingleIdentEntity" passed to the choice field must have a "__toString()" method defined (or you can also override the "property" option).
+ */
+ public function testEntitesMustHaveAToStringMethod()
+ {
+ $entity1 = new SingleIdentEntity(1, 'Foo');
+ $entity2 = new SingleIdentEntity(2, 'Bar');
+
+ // Persist for managed state
+ $this->em->persist($entity1);
+ $this->em->persist($entity2);
+
+ $choiceList = new EntityChoiceList(
+ $this->em,
+ self::SINGLE_IDENT_CLASS,
+ null,
+ null,
+ array(
+ $entity1,
+ $entity2,
+ )
+ );
+
+ $choiceList->getEntities();
+ }
+
+ /**
+ * @expectedException Symfony\Component\Form\Exception\FormException
*/
public function testChoicesMustBeManaged()
{
View
17 tests/Symfony/Tests/Component/DependencyInjection/ParameterBag/ParameterBagTest.php
@@ -94,6 +94,7 @@ public function testResolveValue()
$this->assertEquals(array('bar' => array('bar' => array('bar' => 'bar'))), $bag->resolveValue(array('%foo%' => array('%foo%' => array('%foo%' => '%foo%')))), '->resolveValue() replaces placeholders in nested arrays');
$this->assertEquals('I\'m a %%foo%%', $bag->resolveValue('I\'m a %%foo%%'), '->resolveValue() supports % escaping by doubling it');
$this->assertEquals('I\'m a bar %%foo bar', $bag->resolveValue('I\'m a %foo% %%foo %foo%'), '->resolveValue() supports % escaping by doubling it');
+ $this->assertEquals(array('foo' => array('bar' => array('ding' => 'I\'m a bar %%foo %%bar'))), $bag->resolveValue(array('foo' => array('bar' => array('ding' => 'I\'m a bar %%foo %%bar')))), '->resolveValue() supports % escaping by doubling it');
$bag = new ParameterBag(array('foo' => true));
$this->assertTrue($bag->resolveValue('%foo%'), '->resolveValue() replaces arguments that are just a placeholder by their value without casting them to strings');
@@ -167,6 +168,22 @@ public function testResolveIndicatesWhyAParameterIsNeeded()
/**
* @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::resolve
+ */
+ public function testResolveUnespacesValue()
+ {
+ $bag = new ParameterBag(array(
+ 'foo' => array('bar' => array('ding' => 'I\'m a bar %%foo %%bar')),
+ 'bar' => 'I\'m a %%foo%%',
+ ));
+
+ $bag->resolve();
+
+ $this->assertEquals('I\'m a %foo%', $bag->get('bar'), '->resolveValue() supports % escaping by doubling it');
+ $this->assertEquals(array('bar' => array('ding' => 'I\'m a bar %foo %bar')), $bag->get('foo'), '->resolveValue() supports % escaping by doubling it');
+ }
+
+ /**
+ * @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::resolve
* @dataProvider stringsWithSpacesProvider
*/
public function testResolveStringWithSpacesReturnsString($expected, $test, $description)
View
9 tests/Symfony/Tests/Component/Form/Extension/Core/Type/MoneyTypeTest.php
@@ -24,4 +24,13 @@ public function testPassMoneyPatternToView()
$this->assertSame('{{ widget }} €', $view->get('money_pattern'));
}
+
+ public function testMoneyPatternWorksForYen()
+ {
+ \Locale::setDefault('en_US');
+
+ $form = $this->factory->create('money', null, array('currency' => 'JPY'));
+ $view = $form->createView();
+ $this->assertTrue((Boolean) strstr($view->get('money_pattern'), '¥'));
+ }
}
View
11 tests/Symfony/Tests/Component/HttpKernel/HttpCache/EsiTest.php
@@ -114,6 +114,17 @@ public function testProcess()
$this->assertEquals('foo <?php echo $this->esi->handle($this, \'...\', \'\', false) ?>'."\n", $response->getContent());
}
+ public function testProcessEscapesPhpTags()
+ {
+ $esi = new Esi();
+
+ $request = Request::create('/');
+ $response = new Response('foo <?php die("foo"); ?><%= "lala" %>');
+ $esi->process($request, $response);
+
+ $this->assertEquals('foo <?php echo "<?"; ?>php die("foo"); ?><?php echo "<%"; ?>= "lala" %>', $response->getContent());
+ }
+
/**
* @expectedException RuntimeException
*/
Please sign in to comment.
Something went wrong with that request. Please try again.