Optimize assertLocale regexp

This commit is contained in:
Jérémy Derussé 2014-07-22 23:54:07 +02:00
parent 9572918064
commit 537c39b11e

View File

@ -308,7 +308,7 @@ class Translator implements TranslatorInterface
*/ */
private function assertValidLocale($locale) private function assertValidLocale($locale)
{ {
if (0 !== preg_match('/[^a-z0-9@_\\.\\-]+/i', $locale, $match)) { if (1 !== preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) {
throw new \InvalidArgumentException(sprintf('Invalid locale: %s.', $locale)); throw new \InvalidArgumentException(sprintf('Invalid locale: %s.', $locale));
} }
} }