Skip to content

Commit d06de93

Browse files
committed
Merge branch '2.4' into 2.5
* 2.4: updated VERSION for 2.4.7 updated CHANGELOG for 2.4.7 bumped Symfony version to 2.3.18 updated VERSION for 2.3.17 update CONTRIBUTORS for 2.3.17 updated CHANGELOG for 2.3.17 added XSD to PHPUnit configuration add missing docblock for ProcessBuilder::addEnvironmentVariables() bug #11319 [HttpKernel] Ensure the storage exists before purging it in ProfilerTest [Translation] Added unescaping of ids in PoFileLoader updated italian translation for validation messages [DomCrawler] Fix docblocks and formatting. [DomCrawler] Remove the query string and the anchor of the uri of a link Simplified the Travis test command Remove Expression Language services when the component is unavailable [Console] Make sure formatter is the same Conflicts: src/Symfony/Component/HttpKernel/Kernel.php
2 parents 5f23265 + 2465aa6 commit d06de93

File tree

5 files changed

+48
-5
lines changed

5 files changed

+48
-5
lines changed

Loader/PoFileLoader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private function parse($resource)
157157
private function addMessage(array &$messages, array $item)
158158
{
159159
if (is_array($item['translated'])) {
160-
$messages[$item['ids']['singular']] = stripcslashes($item['translated'][0]);
160+
$messages[stripcslashes($item['ids']['singular'])] = stripcslashes($item['translated'][0]);
161161
if (isset($item['ids']['plural'])) {
162162
$plurals = $item['translated'];
163163
// PO are by definition indexed so sort by index.
@@ -169,10 +169,10 @@ private function addMessage(array &$messages, array $item)
169169
$empties = array_fill(0, $count+1, '-');
170170
$plurals += $empties;
171171
ksort($plurals);
172-
$messages[$item['ids']['plural']] = stripcslashes(implode('|', $plurals));
172+
$messages[stripcslashes($item['ids']['plural'])] = stripcslashes(implode('|', $plurals));
173173
}
174174
} elseif (!empty($item['ids']['singular'])) {
175-
$messages[$item['ids']['singular']] = stripcslashes($item['translated']);
175+
$messages[stripcslashes($item['ids']['singular'])] = stripcslashes($item['translated']);
176176
}
177177
}
178178
}

Tests/Loader/PoFileLoaderTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,28 @@ public function testLoadEmptyTranslation()
6969
$this->assertEquals('en', $catalogue->getLocale());
7070
$this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
7171
}
72+
73+
public function testEscapedId()
74+
{
75+
$loader = new PoFileLoader();
76+
$resource = __DIR__.'/../fixtures/escaped-id.po';
77+
$catalogue = $loader->load($resource, 'en', 'domain1');
78+
79+
$messages = $catalogue->all('domain1');
80+
$this->assertArrayHasKey('escaped "foo"', $messages);
81+
$this->assertEquals('escaped "bar"', $messages['escaped "foo"']);
82+
}
83+
84+
public function testEscapedIdPlurals()
85+
{
86+
$loader = new PoFileLoader();
87+
$resource = __DIR__.'/../fixtures/escaped-id-plurals.po';
88+
$catalogue = $loader->load($resource, 'en', 'domain1');
89+
90+
$messages = $catalogue->all('domain1');
91+
$this->assertArrayHasKey('escaped "foo"', $messages);
92+
$this->assertArrayHasKey('escaped "foos"', $messages);
93+
$this->assertEquals('escaped "bar"', $messages['escaped "foo"']);
94+
$this->assertEquals('escaped "bar"|escaped "bars"', $messages['escaped "foos"']);
95+
}
7296
}

Tests/fixtures/escaped-id-plurals.po

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
msgid ""
2+
msgstr ""
3+
"Content-Type: text/plain; charset=UTF-8\n"
4+
"Content-Transfer-Encoding: 8bit\n"
5+
"Language: en\n"
6+
7+
msgid "escaped \"foo\""
8+
msgid_plural "escaped \"foos\""
9+
msgstr[0] "escaped \"bar\""
10+
msgstr[1] "escaped \"bars\""

Tests/fixtures/escaped-id.po

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
msgid ""
2+
msgstr ""
3+
"Content-Type: text/plain; charset=UTF-8\n"
4+
"Content-Transfer-Encoding: 8bit\n"
5+
"Language: en\n"
6+
7+
msgid "escaped \"foo\""
8+
msgstr "escaped \"bar\""

phpunit.xml.dist

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<phpunit backupGlobals="false"
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
5+
backupGlobals="false"
46
backupStaticAttributes="false"
57
colors="true"
68
convertErrorsToExceptions="true"
79
convertNoticesToExceptions="true"
810
convertWarningsToExceptions="true"
911
processIsolation="false"
1012
stopOnFailure="false"
11-
syntaxCheck="false"
1213
bootstrap="vendor/autoload.php"
1314
>
1415
<testsuites>

0 commit comments

Comments
 (0)