diff --git a/src/Symfony/Bridge/Twig/Node/TransNode.php b/src/Symfony/Bridge/Twig/Node/TransNode.php
index a68c101ab0..924f2b9298 100644
--- a/src/Symfony/Bridge/Twig/Node/TransNode.php
+++ b/src/Symfony/Bridge/Twig/Node/TransNode.php
@@ -95,22 +95,10 @@ class TransNode extends \Twig_Node
preg_match_all('/(?=')) {
- foreach ($matches[1] as $var) {
- $key = new \Twig_Node_Expression_Constant('%'.$var.'%', $body->getLine());
- if (!$vars->hasElement($key)) {
- $vars->addElement(new \Twig_Node_Expression_Name($var, $body->getLine()), $key);
- }
- }
- } else {
- $current = array();
- foreach ($vars as $name => $var) {
- $current[$name] = true;
- }
- foreach ($matches[1] as $var) {
- if (!isset($current['%'.$var.'%'])) {
- $vars->setNode('%'.$var.'%', new \Twig_Node_Expression_Name($var, $body->getLine()));
- }
+ foreach ($matches[1] as $var) {
+ $key = new \Twig_Node_Expression_Constant('%'.$var.'%', $body->getLine());
+ if (!$vars->hasElement($key)) {
+ $vars->addElement(new \Twig_Node_Expression_Name($var, $body->getLine()), $key);
}
}
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php
index e39e8fe06f..c2e6089dbd 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php
@@ -43,6 +43,33 @@ class TranslationExtensionTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expected, $this->getTemplate($template)->render($variables));
}
+ /**
+ * @expectedException \Twig_Error_Syntax
+ * @expectedExceptionMessage Unexpected token. Twig was looking for the "with", "from", or "into" keyword in "index" at line 3.
+ */
+ public function testTransUnknownKeyword()
+ {
+ $output = $this->getTemplate("{% trans \n\nfoo %}{% endtrans %}")->render();
+ }
+
+ /**
+ * @expectedException \Twig_Error_Syntax
+ * @expectedExceptionMessage A message inside a trans tag must be a simple text in "index" at line 2.
+ */
+ public function testTransComplexBody()
+ {
+ $output = $this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render();
+ }
+
+ /**
+ * @expectedException \Twig_Error_Syntax
+ * @expectedExceptionMessage A message inside a transchoice tag must be a simple text in "index" at line 2.
+ */
+ public function testTransChoiceComplexBody()
+ {
+ $output = $this->getTemplate("{% transchoice count %}\n{{ 1 + 2 }}{% endtranschoice %}")->render();
+ }
+
public function getTransTests()
{
return array(
diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php
index be8ac5cfaa..1c75d8bb85 100644
--- a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php
+++ b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php
@@ -64,7 +64,7 @@ class TransChoiceTokenParser extends TransTokenParser
$body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
- throw new \Twig_Error_Syntax('A message must be a simple text.');
+ throw new \Twig_Error_Syntax('A message inside a transchoice tag must be a simple text.', $body->getLine(), $stream->getFilename());
}
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php
index a11681c249..86f9579cf6 100644
--- a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php
+++ b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php
@@ -55,7 +55,7 @@ class TransTokenParser extends \Twig_TokenParser
$stream->next();
$locale = $this->parser->getExpressionParser()->parseExpression();
} elseif (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
- throw new \Twig_Error_Syntax('Unexpected token. Twig was looking for the "with" or "from" keyword.');
+ throw new \Twig_Error_Syntax('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getFilename());
}
}
@@ -64,7 +64,7 @@ class TransTokenParser extends \Twig_TokenParser
$body = $this->parser->subparse(array($this, 'decideTransFork'), true);
if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
- throw new \Twig_Error_Syntax('A message inside a trans tag must be a simple text');
+ throw new \Twig_Error_Syntax('A message inside a trans tag must be a simple text.', $body->getLine(), $stream->getFilename());
}
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
diff --git a/src/Symfony/Component/DependencyInjection/services10.xml b/src/Symfony/Component/DependencyInjection/services10.xml
deleted file mode 100644
index 824d8b5d75..0000000000
--- a/src/Symfony/Component/DependencyInjection/services10.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
diff --git a/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php b/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php
index 794e966ac6..987b78b5c7 100644
--- a/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php
+++ b/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php
@@ -33,7 +33,7 @@ class TextareaFormField extends FormField
$this->value = null;
foreach ($this->node->childNodes as $node) {
- $this->value .= $this->document->saveXML($node);
+ $this->value .= $node->wholeText;
}
}
}
diff --git a/src/Symfony/Component/DomCrawler/Tests/Field/TextareaFormFieldTest.php b/src/Symfony/Component/DomCrawler/Tests/Field/TextareaFormFieldTest.php
index a33c44f230..5d4d003826 100644
--- a/src/Symfony/Component/DomCrawler/Tests/Field/TextareaFormFieldTest.php
+++ b/src/Symfony/Component/DomCrawler/Tests/Field/TextareaFormFieldTest.php
@@ -29,5 +29,18 @@ class TextareaFormFieldTest extends FormFieldTestCase
} catch (\LogicException $e) {
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is not a textarea');
}
+
+ // Ensure that valid HTML can be used on a textarea.
+ $node = $this->createNode('textarea', 'foo bar
Baz
');
+ $field = new TextareaFormField($node);
+
+ $this->assertEquals('foo bar
Baz
', $field->getValue(), '->initialize() sets the value of the field to the textarea node value');
+
+ // Ensure that we don't do any DOM manipulation/validation by passing in
+ // "invalid" HTML.
+ $node = $this->createNode('textarea', 'foo bar
Baz');
+ $field = new TextareaFormField($node);
+
+ $this->assertEquals('foo bar