Skip to content

Commit 6c11d55

Browse files
committed
Merge branch '2.3' into 2.4
* 2.3: fixed CS allow the TextAreaFormField to be used with valid/invalid HTML Create security.id.xlf [DependencyInjection] Remove unneeded file [Twig] removed obsolete conditions on Twig versions added lines to exceptions for the trans and transchoice tags [Form] Make FormInterface::add docblock more explicit [Security] Add zh_CN translations [Validator][Translation]update zh_CN translations [Validator] Minor fix in XmlLoader
2 parents 65ea988 + 9b27d8a commit 6c11d55

File tree

13 files changed

+307
-90
lines changed

13 files changed

+307
-90
lines changed

src/Symfony/Bridge/Twig/Node/TransNode.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,10 @@ protected function compileString(\Twig_NodeInterface $body, \Twig_Node_Expressio
9595

9696
preg_match_all('/(?<!%)%([^%]+)%/', $msg, $matches);
9797

98-
if (version_compare(\Twig_Environment::VERSION, '1.5', '>=')) {
99-
foreach ($matches[1] as $var) {
100-
$key = new \Twig_Node_Expression_Constant('%'.$var.'%', $body->getLine());
101-
if (!$vars->hasElement($key)) {
102-
$vars->addElement(new \Twig_Node_Expression_Name($var, $body->getLine()), $key);
103-
}
104-
}
105-
} else {
106-
$current = array();
107-
foreach ($vars as $name => $var) {
108-
$current[$name] = true;
109-
}
110-
foreach ($matches[1] as $var) {
111-
if (!isset($current['%'.$var.'%'])) {
112-
$vars->setNode('%'.$var.'%', new \Twig_Node_Expression_Name($var, $body->getLine()));
113-
}
98+
foreach ($matches[1] as $var) {
99+
$key = new \Twig_Node_Expression_Constant('%'.$var.'%', $body->getLine());
100+
if (!$vars->hasElement($key)) {
101+
$vars->addElement(new \Twig_Node_Expression_Name($var, $body->getLine()), $key);
114102
}
115103
}
116104

src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,33 @@ public function testTrans($template, $expected, array $variables = array())
4343
$this->assertEquals($expected, $this->getTemplate($template)->render($variables));
4444
}
4545

46+
/**
47+
* @expectedException \Twig_Error_Syntax
48+
* @expectedExceptionMessage Unexpected token. Twig was looking for the "with", "from", or "into" keyword in "index" at line 3.
49+
*/
50+
public function testTransUnknownKeyword()
51+
{
52+
$output = $this->getTemplate("{% trans \n\nfoo %}{% endtrans %}")->render();
53+
}
54+
55+
/**
56+
* @expectedException \Twig_Error_Syntax
57+
* @expectedExceptionMessage A message inside a trans tag must be a simple text in "index" at line 2.
58+
*/
59+
public function testTransComplexBody()
60+
{
61+
$output = $this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render();
62+
}
63+
64+
/**
65+
* @expectedException \Twig_Error_Syntax
66+
* @expectedExceptionMessage A message inside a transchoice tag must be a simple text in "index" at line 2.
67+
*/
68+
public function testTransChoiceComplexBody()
69+
{
70+
$output = $this->getTemplate("{% transchoice count %}\n{{ 1 + 2 }}{% endtranschoice %}")->render();
71+
}
72+
4673
public function getTransTests()
4774
{
4875
return array(

src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function parse(\Twig_Token $token)
6464
$body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
6565

6666
if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
67-
throw new \Twig_Error_Syntax('A message must be a simple text.');
67+
throw new \Twig_Error_Syntax('A message inside a transchoice tag must be a simple text.', $body->getLine(), $stream->getFilename());
6868
}
6969

7070
$stream->expect(\Twig_Token::BLOCK_END_TYPE);

src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function parse(\Twig_Token $token)
5555
$stream->next();
5656
$locale = $this->parser->getExpressionParser()->parseExpression();
5757
} elseif (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
58-
throw new \Twig_Error_Syntax('Unexpected token. Twig was looking for the "with" or "from" keyword.');
58+
throw new \Twig_Error_Syntax('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getFilename());
5959
}
6060
}
6161

@@ -64,7 +64,7 @@ public function parse(\Twig_Token $token)
6464
$body = $this->parser->subparse(array($this, 'decideTransFork'), true);
6565

6666
if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
67-
throw new \Twig_Error_Syntax('A message inside a trans tag must be a simple text');
67+
throw new \Twig_Error_Syntax('A message inside a trans tag must be a simple text.', $body->getLine(), $stream->getFilename());
6868
}
6969

7070
$stream->expect(\Twig_Token::BLOCK_END_TYPE);

src/Symfony/Component/DependencyInjection/services10.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Symfony/Component/DomCrawler/Field/TextareaFormField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function initialize()
3333

3434
$this->value = null;
3535
foreach ($this->node->childNodes as $node) {
36-
$this->value .= $this->document->saveXML($node);
36+
$this->value .= $node->wholeText;
3737
}
3838
}
3939
}

src/Symfony/Component/DomCrawler/Tests/Field/TextareaFormFieldTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,18 @@ public function testInitialize()
2929
} catch (\LogicException $e) {
3030
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is not a textarea');
3131
}
32+
33+
// Ensure that valid HTML can be used on a textarea.
34+
$node = $this->createNode('textarea', 'foo bar <h1>Baz</h1>');
35+
$field = new TextareaFormField($node);
36+
37+
$this->assertEquals('foo bar <h1>Baz</h1>', $field->getValue(), '->initialize() sets the value of the field to the textarea node value');
38+
39+
// Ensure that we don't do any DOM manipulation/validation by passing in
40+
// "invalid" HTML.
41+
$node = $this->createNode('textarea', 'foo bar <h1>Baz</h2>');
42+
$field = new TextareaFormField($node);
43+
44+
$this->assertEquals('foo bar <h1>Baz</h2>', $field->getValue(), '->initialize() sets the value of the field to the textarea node value');
3245
}
3346
}

src/Symfony/Component/Form/FormInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function setParent(FormInterface $parent = null);
3939
public function getParent();
4040

4141
/**
42-
* Adds a child to the form.
42+
* Adds or replaces a child to the form.
4343
*
4444
* @param FormInterface|string|integer $child The FormInterface instance or the name of the child.
4545
* @param string|null $type The child's type, if a name was passed.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0"?>
2+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3+
<file source-language="en" datatype="plaintext" original="file.ext">
4+
<body>
5+
<trans-unit id="1">
6+
<source>An authentication exception occurred.</source>
7+
<target>Terjadi sebuah pengecualian otentikasi.</target>
8+
</trans-unit>
9+
<trans-unit id="2">
10+
<source>Authentication credentials could not be found.</source>
11+
<target>Kredensial otentikasi tidak bisa ditemukan.</target>
12+
</trans-unit>
13+
<trans-unit id="3">
14+
<source>Authentication request could not be processed due to a system problem.</source>
15+
<target>Permintaan otentikasi tidak bisa diproses karena masalah sistem.</target>
16+
</trans-unit>
17+
<trans-unit id="4">
18+
<source>Invalid credentials.</source>
19+
<target>Kredensial salah.</target>
20+
</trans-unit>
21+
<trans-unit id="5">
22+
<source>Cookie has already been used by someone else.</source>
23+
<target>Cookie sudah digunakan oleh orang lain.</target>
24+
</trans-unit>
25+
<trans-unit id="6">
26+
<source>Not privileged to request the resource.</source>
27+
<target>Tidak berhak untuk meminta sumber daya.</target>
28+
</trans-unit>
29+
<trans-unit id="7">
30+
<source>Invalid CSRF token.</source>
31+
<target>Token CSRF salah.</target>
32+
</trans-unit>
33+
<trans-unit id="8">
34+
<source>Digest nonce has expired.</source>
35+
<target>Digest nonce telah berakhir.</target>
36+
</trans-unit>
37+
<trans-unit id="9">
38+
<source>No authentication provider found to support the authentication token.</source>
39+
<target>Tidak ditemukan penyedia otentikasi untuk mendukung token otentikasi.</target>
40+
</trans-unit>
41+
<trans-unit id="10">
42+
<source>No session available, it either timed out or cookies are not enabled.</source>
43+
<target>Tidak ada sesi yang tersedia, mungkin waktu sudah habis atau cookie tidak diaktifkan</target>
44+
</trans-unit>
45+
<trans-unit id="11">
46+
<source>No token could be found.</source>
47+
<target>Tidak ada token yang bisa ditemukan.</target>
48+
</trans-unit>
49+
<trans-unit id="12">
50+
<source>Username could not be found.</source>
51+
<target>Username tidak bisa ditemukan.</target>
52+
</trans-unit>
53+
<trans-unit id="13">
54+
<source>Account has expired.</source>
55+
<target>Akun telah berakhir.</target>
56+
</trans-unit>
57+
<trans-unit id="14">
58+
<source>Credentials have expired.</source>
59+
<target>Kredensial telah berakhir.</target>
60+
</trans-unit>
61+
<trans-unit id="15">
62+
<source>Account is disabled.</source>
63+
<target>Akun dinonaktifkan.</target>
64+
</trans-unit>
65+
<trans-unit id="16">
66+
<source>Account is locked.</source>
67+
<target>Akun terkunci.</target>
68+
</trans-unit>
69+
</body>
70+
</file>
71+
</xliff>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0"?>
2+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3+
<file source-language="en" datatype="plaintext" original="file.ext">
4+
<body>
5+
<trans-unit id="1">
6+
<source>An authentication exception occurred.</source>
7+
<target>身份验证发生异常。</target>
8+
</trans-unit>
9+
<trans-unit id="2">
10+
<source>Authentication credentials could not be found.</source>
11+
<target>没有找到身份验证的凭证。</target>
12+
</trans-unit>
13+
<trans-unit id="3">
14+
<source>Authentication request could not be processed due to a system problem.</source>
15+
<target>由于系统故障,身份验证的请求无法被处理。</target>
16+
</trans-unit>
17+
<trans-unit id="4">
18+
<source>Invalid credentials.</source>
19+
<target>无效的凭证。</target>
20+
</trans-unit>
21+
<trans-unit id="5">
22+
<source>Cookie has already been used by someone else.</source>
23+
<target>Cookie 已经被其他人使用。</target>
24+
</trans-unit>
25+
<trans-unit id="6">
26+
<source>Not privileged to request the resource.</source>
27+
<target>没有权限请求此资源。</target>
28+
</trans-unit>
29+
<trans-unit id="7">
30+
<source>Invalid CSRF token.</source>
31+
<target>无效的 CSRF token 。</target>
32+
</trans-unit>
33+
<trans-unit id="8">
34+
<source>Digest nonce has expired.</source>
35+
<target>摘要随机串(digest nonce)已过期。</target>
36+
</trans-unit>
37+
<trans-unit id="9">
38+
<source>No authentication provider found to support the authentication token.</source>
39+
<target>没有找到支持此 token 的身份验证服务提供方。</target>
40+
</trans-unit>
41+
<trans-unit id="10">
42+
<source>No session available, it either timed out or cookies are not enabled.</source>
43+
<target>Session 不可用。会话超时或没有启用 cookies 。</target>
44+
</trans-unit>
45+
<trans-unit id="11">
46+
<source>No token could be found.</source>
47+
<target>找不到 token 。</target>
48+
</trans-unit>
49+
<trans-unit id="12">
50+
<source>Username could not be found.</source>
51+
<target>找不到用户名。</target>
52+
</trans-unit>
53+
<trans-unit id="13">
54+
<source>Account has expired.</source>
55+
<target>帐号已过期。</target>
56+
</trans-unit>
57+
<trans-unit id="14">
58+
<source>Credentials have expired.</source>
59+
<target>凭证已过期。</target>
60+
</trans-unit>
61+
<trans-unit id="15">
62+
<source>Account is disabled.</source>
63+
<target>帐号已被禁用。</target>
64+
</trans-unit>
65+
<trans-unit id="16">
66+
<source>Account is locked.</source>
67+
<target>帐号已被锁定。</target>
68+
</trans-unit>
69+
</body>
70+
</file>
71+
</xliff>

src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ protected function addNamespaceAlias($alias, $namespace)
3636
/**
3737
* Creates a new constraint instance for the given constraint name.
3838
*
39-
* @param string $name The constraint name. Either a constraint relative
40-
* to the default constraint namespace, or a fully
41-
* qualified class name
42-
* @param array $options The constraint options
39+
* @param string $name The constraint name. Either a constraint relative
40+
* to the default constraint namespace, or a fully
41+
* qualified class name
42+
* @param mixed $options The constraint options
4343
*
4444
* @return Constraint
4545
*

src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ protected function parseConstraints(\SimpleXMLElement $nodes)
105105
$options = null;
106106
}
107107

108-
$constraints[] = $this->newConstraint($node['name'], $options);
108+
$constraints[] = $this->newConstraint((string) $node['name'], $options);
109109
}
110110

111111
return $constraints;

0 commit comments

Comments
 (0)