Skip to content

Commit 2fd964e

Browse files
committed
Merge branch '2.5'
* 2.5: [Translator] Use quote to surround invalid locale [Validator] Fixed memory leak in ValidatorBuilder [FrameworkBundle] changed KernelTestCase::getKernelClass() to check $_SERVER['KERNEL_DIR'] before invoking getPhpUnitXmlDir() Optimize assertLocale regexp [ExpressionLanguage] Fixed an issue with # characters in double quoted string literals [Validator] Fixed object initializers in 2.5 version of the Validator Add some tweaks to the pt_BR translations [Validator] Backported #11410 to 2.3: Object initializers are called only once per object [Translator][FrameworkBundle] Added @ to the list of allowed chars in Translator [Process] Reduce I/O load on Windows platform [Form] Check if IntlDateFormatter constructor returned a valid object before using it Conflicts: src/Symfony/Component/Process/ProcessPipes.php
2 parents 5e55b55 + 9f09786 commit 2fd964e

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

Tests/TranslatorTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ public function testSetFallbackLocalesMultiple()
103103
$this->assertEquals('bar (fr)', $translator->trans('bar'));
104104
}
105105

106-
107106
/**
108107
* @dataProvider getInvalidLocalesTests
109108
* @expectedException \InvalidArgumentException
@@ -329,7 +328,6 @@ public function testTransChoiceValidLocale($locale)
329328
// no assertion. this method just asserts that no exception is thrown
330329
}
331330

332-
333331
public function getTransFileTests()
334332
{
335333
return array(
@@ -430,6 +428,7 @@ public function getValidLocalesTests()
430428
array('fr_FR'),
431429
array('fr.FR'),
432430
array('fr-FR.UTF8'),
431+
array('sr@latin'),
433432
);
434433
}
435434

Translator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ protected function computeFallbackLocales($locale)
318318
*/
319319
private function assertValidLocale($locale)
320320
{
321-
if (0 !== preg_match('/[^a-z0-9_\\.\\-]+/i', $locale, $match)) {
322-
throw new \InvalidArgumentException(sprintf('Invalid locale: %s.', $locale));
321+
if (1 !== preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) {
322+
throw new \InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale));
323323
}
324324
}
325325
}

0 commit comments

Comments
 (0)