Merge branch '2.0' into 2.1

* 2.0:
  fixed comment. The parent ACL is not accessed in this method.
  [HttpFoundation] Make host & methods really case insensitive in the RequestMacther
  [Validator] fixed Ukrainian language code (closes #5972)
  Fixed case of php function

Conflicts:
	src/Symfony/Bundle/FrameworkBundle/Resources/translations/validators.uk.xliff
	src/Symfony/Component/HttpFoundation/RequestMatcher.php
This commit is contained in:
Fabien Potencier 2012-11-13 17:28:15 +01:00
commit 2d488b79f2
6 changed files with 232 additions and 260 deletions

View File

@ -33,7 +33,7 @@ class RequestMatcher implements RequestMatcherInterface
/**
* @var array
*/
private $methods;
private $methods = array();
/**
* @var string
@ -41,19 +41,26 @@ class RequestMatcher implements RequestMatcherInterface
private $ip;
/**
* Attributes.
*
* @var array
*/
private $attributes;
private $attributes = array();
/**
* @param string|null $path
* @param string|null $host
* @param string|string[]|null $methods
* @param string|null $ip
* @param array $attributes
*/
public function __construct($path = null, $host = null, $methods = null, $ip = null, array $attributes = array())
{
$this->path = $path;
$this->host = $host;
$this->methods = $methods;
$this->ip = $ip;
$this->attributes = $attributes;
$this->matchPath($path);
$this->matchHost($host);
$this->matchMethod($methods);
$this->matchIp($ip);
foreach ($attributes as $k => $v) {
$this->matchAttribute($k, $v);
}
}
/**
@ -89,11 +96,11 @@ class RequestMatcher implements RequestMatcherInterface
/**
* Adds a check for the HTTP method.
*
* @param string|array $method An HTTP method or an array of HTTP methods
* @param string|string[]|null $method An HTTP method or an array of HTTP methods
*/
public function matchMethod($method)
{
$this->methods = array_map('strtoupper', is_array($method) ? $method : array($method));
$this->methods = array_map('strtoupper', (array) $method);
}
/**
@ -114,7 +121,7 @@ class RequestMatcher implements RequestMatcherInterface
*/
public function matches(Request $request)
{
if (null !== $this->methods && !in_array($request->getMethod(), $this->methods)) {
if ($this->methods && !in_array($request->getMethod(), $this->methods)) {
return false;
}
@ -132,7 +139,7 @@ class RequestMatcher implements RequestMatcherInterface
}
}
if (null !== $this->host && !preg_match('#'.str_replace('#', '\\#', $this->host).'#', $request->getHost())) {
if (null !== $this->host && !preg_match('#'.str_replace('#', '\\#', $this->host).'#i', $request->getHost())) {
return false;
}
@ -204,7 +211,7 @@ class RequestMatcher implements RequestMatcherInterface
if (false !== strpos($ip, '/')) {
list($address, $netmask) = explode('/', $ip, 2);
if ($netmask < 1 || $netmask > 128) {
return false;
}
@ -228,3 +235,4 @@ class RequestMatcher implements RequestMatcherInterface
return true;
}
}

View File

@ -88,38 +88,59 @@ class RequestMatcherTest extends \PHPUnit_Framework_TestCase
}
}
public function testMethod()
/**
* @dataProvider testMethodFixtures
*/
public function testMethod($requestMethod, $matcherMethod, $isMatch)
{
$matcher = new RequestMatcher();
$matcher->matchMethod($matcherMethod);
$request = Request::create('', $requestMethod);
$this->assertSame($isMatch, $matcher->matches($request));
$matcher->matchMethod('get');
$request = Request::create('', 'get');
$this->assertTrue($matcher->matches($request));
$matcher->matchMethod('post');
$this->assertFalse($matcher->matches($request));
$matcher->matchMethod(array('get', 'post'));
$this->assertTrue($matcher->matches($request));
$matcher = new RequestMatcher(null, null, $matcherMethod);
$request = Request::create('', $requestMethod);
$this->assertSame($isMatch, $matcher->matches($request));
}
public function testHost()
public function testMethodFixtures()
{
return array(
array('get', 'get', true),
array('get', array('get', 'post'), true),
array('get', 'post', false),
array('get', 'GET', true),
array('get', array('GET', 'POST'), true),
array('get', 'POST', false),
);
}
/**
* @dataProvider testHostFixture
*/
public function testHost($pattern, $isMatch)
{
$matcher = new RequestMatcher();
$request = Request::create('', 'get', array(), array(), array(), array('HTTP_HOST' => 'foo.example.com'));
$matcher->matchHost('.*\.example\.com');
$this->assertTrue($matcher->matches($request));
$matcher->matchHost($pattern);
$this->assertSame($isMatch, $matcher->matches($request));
$matcher->matchHost('\.example\.com$');
$this->assertTrue($matcher->matches($request));
$matcher= new RequestMatcher(null, $pattern);
$this->assertSame($isMatch, $matcher->matches($request));
}
$matcher->matchHost('^.*\.example\.com$');
$this->assertTrue($matcher->matches($request));
$matcher->matchMethod('.*\.sensio\.com');
$this->assertFalse($matcher->matches($request));
public function testHostFixture()
{
return array(
array('.*\.example\.com', true),
array('\.example\.com$', true),
array('^.*\.example\.com$', true),
array('.*\.sensio\.com', false),
array('.*\.example\.COM', true),
array('\.example\.COM$', true),
array('^.*\.example\.COM$', true),
array('.*\.sensio\.COM', false), );
}
public function testPath()
@ -179,3 +200,4 @@ class RequestMatcherTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($matcher->matches($request));
}
}

View File

@ -186,7 +186,7 @@ class StubIntlDateFormatter
$argumentError = null;
if (version_compare(\PHP_VERSION, '5.3.4', '<') && !is_int($timestamp)) {
$argumentError = 'datefmt_format: takes either an array or an integer timestamp value ';
} elseif (version_compare(\PHP_VERSION, '5.3.4', '>=') && !is_int($timestamp) && !$timestamp instanceOf \DateTime) {
} elseif (version_compare(\PHP_VERSION, '5.3.4', '>=') && !is_int($timestamp) && !$timestamp instanceof \DateTime) {
$argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object';
}
@ -199,7 +199,7 @@ class StubIntlDateFormatter
}
// As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances
if (version_compare(\PHP_VERSION, '5.3.4', '>=') && $timestamp instanceOf \DateTime) {
if (version_compare(\PHP_VERSION, '5.3.4', '>=') && $timestamp instanceof \DateTime) {
$timestamp = $timestamp->getTimestamp();
}

View File

@ -120,10 +120,8 @@ class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface
* permission/identity combination.
*
* This process is repeated until either a granting ACE is found, or no
* permission/identity combinations are left. In the latter case, we will
* call this method on the parent ACL if it exists, and isEntriesInheriting
* is true. Otherwise, we will either throw an NoAceFoundException, or deny
* access finally.
* permission/identity combinations are left. Finally, we will either throw
* an NoAceFoundException, or deny access.
*
* @param AclInterface $acl
* @param array $aces An array of ACE to check against

View File

@ -1,219 +0,0 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>This value should be false.</source>
<target>Значення повинно бути Ні.</target>
</trans-unit>
<trans-unit id="2">
<source>This value should be true.</source>
<target>Значення повинно бути Так.</target>
</trans-unit>
<trans-unit id="3">
<source>This value should be of type {{ type }}.</source>
<target>Тип значення повинен бути {{ type }}.</target>
</trans-unit>
<trans-unit id="4">
<source>This value should be blank.</source>
<target>Значення повинно бути пустим.</target>
</trans-unit>
<trans-unit id="5">
<source>The value you selected is not a valid choice.</source>
<target>Обране вами значення недопустиме.</target>
</trans-unit>
<trans-unit id="6">
<source>You must select at least {{ limit }} choices.</source>
<target>Ви повинні обрати хоча б {{ limit }} варіантів.</target>
</trans-unit>
<trans-unit id="7">
<source>You must select at most {{ limit }} choices.</source>
<target>Ви повинні обрати не більше ніж {{ limit }} варіантів.</target>
</trans-unit>
<trans-unit id="8">
<source>One or more of the given values is invalid.</source>
<target>Одне або кілька заданих значень є недопустимі.</target>
</trans-unit>
<trans-unit id="9">
<source>The fields {{ fields }} were not expected.</source>
<target>Поля {{ fields }} не очікувалися.</target>
</trans-unit>
<trans-unit id="10">
<source>The fields {{ fields }} are missing.</source>
<target>Поля {{ fields }} відсутні.</target>
</trans-unit>
<trans-unit id="11">
<source>This value is not a valid date.</source>
<target>Дане значення не є вірною датою.</target>
</trans-unit>
<trans-unit id="12">
<source>This value is not a valid datetime.</source>
<target>Дане значення дати та часу недопустиме.</target>
</trans-unit>
<trans-unit id="13">
<source>This value is not a valid email address.</source>
<target>Значення адреси электронної пошти недопустиме.</target>
</trans-unit>
<trans-unit id="14">
<source>The file could not be found.</source>
<target>Файл не знайдено.</target>
</trans-unit>
<trans-unit id="15">
<source>The file is not readable.</source>
<target>Файл не читається.</target>
</trans-unit>
<trans-unit id="16">
<source>The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}.</source>
<target>Файл занадто великий ({{ size }} {{ suffix }}). Дозволений максимальний розмір {{ limit }} {{ suffix }}.</target>
</trans-unit>
<trans-unit id="17">
<source>The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}.</source>
<target>MIME-тип файлу недопустимий ({{ type }}). Допустимі MIME-типи файлів {{ types }}.</target>
</trans-unit>
<trans-unit id="18">
<source>This value should be {{ limit }} or less.</source>
<target>Значення повинно бути {{ limit }} або менше.</target>
</trans-unit>
<trans-unit id="19">
<source>This value is too long. It should have {{ limit }} characters or less.</source>
<target>Значення занадто довге. Повинно бути {{ limit }} символів або менше.</target>
</trans-unit>
<trans-unit id="20">
<source>This value should be {{ limit }} or more.</source>
<target>Значення повинно бути {{ limit }} або більше.</target>
</trans-unit>
<trans-unit id="21">
<source>This value is too short. It should have {{ limit }} characters or more.</source>
<target>Значення занадто коротке. Повинно бути {{ limit }} символів або більше.</target>
</trans-unit>
<trans-unit id="22">
<source>This value should not be blank.</source>
<target>Значення не повинно бути пустим.</target>
</trans-unit>
<trans-unit id="23">
<source>This value should not be null.</source>
<target>Значення не повинно бути null.</target>
</trans-unit>
<trans-unit id="24">
<source>This value should be null.</source>
<target>Значення повинно бути null.</target>
</trans-unit>
<trans-unit id="25">
<source>This value is not valid.</source>
<target>Значення недопустиме.</target>
</trans-unit>
<trans-unit id="26">
<source>This value is not a valid time.</source>
<target>Значення часу недопустиме.</target>
</trans-unit>
<trans-unit id="27">
<source>This value is not a valid URL.</source>
<target>Значення URL недопустиме.</target>
</trans-unit>
<trans-unit id="31">
<source>The two values should be equal.</source>
<target>Обидва занчення повинні бути одинаковими.</target>
</trans-unit>
<trans-unit id="32">
<source>The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}.</source>
<target>Файл занадто великий. Максимальний допустимий розмір {{ limit }} {{ suffix }}.</target>
</trans-unit>
<trans-unit id="33">
<source>The file is too large.</source>
<target>Файл занадто великий.</target>
</trans-unit>
<trans-unit id="34">
<source>The file could not be uploaded.</source>
<target>Файл не можливо завантажити.</target>
</trans-unit>
<trans-unit id="35">
<source>This value should be a valid number.</source>
<target>Значення має бути допустимим числом.</target>
</trans-unit>
<trans-unit id="36">
<source>This file is not a valid image.</source>
<target>Цей файл не є допустимим форматом зображення.</target>
</trans-unit>
<trans-unit id="37">
<source>This is not a valid IP address.</source>
<target>Значення не є допустимою IP адресою.</target>
</trans-unit>
<trans-unit id="38">
<source>This value is not a valid language.</source>
<target>Значення не є допустимим кодом мови.</target>
</trans-unit>
<trans-unit id="39">
<source>This value is not a valid locale.</source>
<target>Значення не є допустимим значенням локалізації.</target>
</trans-unit>
<trans-unit id="40">
<source>This value is not a valid country.</source>
<target>Значення не є допустимим значенням країни.</target>
</trans-unit>
<trans-unit id="41">
<source>This value is already used.</source>
<target>Значення вже використовується.</target>
</trans-unit>
<trans-unit id="42">
<source>The size of the image could not be detected.</source>
<target>Не можливо визначити розмір зображення.</target>
</trans-unit>
<trans-unit id="43">
<source>The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px.</source>
<target>Ширина зображення занадто велика ({{ width }}px). Максимальна допустима ширина {{ max_width }}px.</target>
</trans-unit>
<trans-unit id="44">
<source>The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px.</source>
<target>Ширина зображення занадто мала ({{ width }}px). Мінімальна допустима ширина {{ min_width }}px.</target>
</trans-unit>
<trans-unit id="45">
<source>The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px.</source>
<target>Висота зображення занадто велика ({{ height }}px). Максимальна допустима висота {{ max_height }}px.</target>
</trans-unit>
<trans-unit id="46">
<source>The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px.</source>
<target>Висота зображення занадто мала ({{ height }}px). Мінімальна допустима висота {{ min_height }}px.</target>
</trans-unit>
<trans-unit id="47">
<source>This value should be the user current password.</source>
<target>Значення має бути поточним паролем користувача.</target>
</trans-unit>
<trans-unit id="48">
<source>This value should have exactly {{ limit }} characters.</source>
<target>Значення повинно бути рівним {{ limit }} символу.|Значення повинно бути рівним {{ limit }} символам.</target>
</trans-unit>
<trans-unit id="49">
<source>The file was only partially uploaded.</source>
<target>Файл було завантажено лише частково.</target>
</trans-unit>
<trans-unit id="50">
<source>No file was uploaded.</source>
<target>Файл не завантажено.</target>
</trans-unit>
<trans-unit id="51">
<source>No temporary folder was configured in php.ini.</source>
<target>Не налаштована тимчасова директорія в php.ini.</target>
</trans-unit>
<trans-unit id="52">
<source>Cannot write temporary file to disk.</source>
<target>Неможливо записати тимчасовий файл на диск.</target>
</trans-unit>
<trans-unit id="53">
<source>A PHP extension caused the upload to fail.</source>
<target>Розширення PHP викликало помилку при завантаженні.</target>
</trans-unit>
<trans-unit id="54">
<source>This collection should contain {{ limit }} elements or more.</source>
<target>Колекція повинна містити {{ limit }} елемент або більше.|Колекція повинна містити {{ limit }} елементи або більше.|Колекція повинна містити {{ limit }} елементів або більше.</target>
</trans-unit>
<trans-unit id="55">
<source>This collection should contain {{ limit }} elements or less.</source>
<target>Колекція повинна містити {{ limit }} елемент або менше.|Колекція повинна містити {{ limit }} елементи або менше.|Колекція повинна містити {{ limit }} елементів або менше.</target>
</trans-unit>
<trans-unit id="56">
<source>This collection should contain exactly {{ limit }} elements.</source>
<target>Колекція повинна містити рівно {{ limit }} елемент.|Колекція повинна містити рівно {{ limit }} елементи.|Колекція повинна містити рівно {{ limit }} елементів.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -0,0 +1,163 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>This value should be false</source>
<target>Значення повинно бути Ні</target>
</trans-unit>
<trans-unit id="2">
<source>This value should be true</source>
<target>Значення повинно бути Так</target>
</trans-unit>
<trans-unit id="3">
<source>This value should be of type {{ type }}</source>
<target>Тип значення повинен бути {{ type }}</target>
</trans-unit>
<trans-unit id="4">
<source>This value should be blank</source>
<target>Значення повинно бути пустим</target>
</trans-unit>
<trans-unit id="5">
<source>The value you selected is not a valid choice</source>
<target>Обране вами значення недопустиме</target>
</trans-unit>
<trans-unit id="6">
<source>You must select at least {{ limit }} choices</source>
<target>Ви повинні обрати хоча б {{ limit }} варіантів</target>
</trans-unit>
<trans-unit id="7">
<source>You must select at most {{ limit }} choices</source>
<target>Ви повинні обрати не більше ніж {{ limit }} варіантів</target>
</trans-unit>
<trans-unit id="8">
<source>One or more of the given values is invalid</source>
<target>Одне або кілька заданих значень є недопустимі</target>
</trans-unit>
<trans-unit id="9">
<source>The fields {{ fields }} were not expected</source>
<target>Поля {{ fields }} не очікувалися</target>
</trans-unit>
<trans-unit id="10">
<source>The fields {{ fields }} are missing</source>
<target>Поля {{ fields }} відсутні</target>
</trans-unit>
<trans-unit id="11">
<source>This value is not a valid date</source>
<target>Дане значення не є вірною датою</target>
</trans-unit>
<trans-unit id="12">
<source>This value is not a valid datetime</source>
<target>Дане значення дати та часу недопустиме</target>
</trans-unit>
<trans-unit id="13">
<source>This value is not a valid email address</source>
<target>Значення адреси электронної пошти недопустиме</target>
</trans-unit>
<trans-unit id="14">
<source>The file could not be found</source>
<target>Файл не знайдено</target>
</trans-unit>
<trans-unit id="15">
<source>The file is not readable</source>
<target>Файл не читається</target>
</trans-unit>
<trans-unit id="16">
<source>The file is too large ({{ size }}). Allowed maximum size is {{ limit }}</source>
<target>Файл занадто великий ({{ size }}). Дозволений максимальний розмір {{ limit }}</target>
</trans-unit>
<trans-unit id="17">
<source>The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}</source>
<target>MIME-тип файлу недопустимий ({{ type }}). Допустимі MIME-типи файлів {{ types }}</target>
</trans-unit>
<trans-unit id="18">
<source>This value should be {{ limit }} or less</source>
<target>Значення повинно бути {{ limit }} або менше</target>
</trans-unit>
<trans-unit id="19">
<source>This value is too long. It should have {{ limit }} characters or less</source>
<target>Значення занадто довге. Повинно бути {{ limit }} символів або менше</target>
</trans-unit>
<trans-unit id="20">
<source>This value should be {{ limit }} or more</source>
<target>Значення повинно бути {{ limit }} або більше</target>
</trans-unit>
<trans-unit id="21">
<source>This value is too short. It should have {{ limit }} characters or more</source>
<target>Значення занадто коротке. Повинно бути {{ limit }} символів або більше</target>
</trans-unit>
<trans-unit id="22">
<source>This value should not be blank</source>
<target>Значення не повинно бути пустим</target>
</trans-unit>
<trans-unit id="23">
<source>This value should not be null</source>
<target>Значення не повинно бути null</target>
</trans-unit>
<trans-unit id="24">
<source>This value should be null</source>
<target>Значення повинно бути null</target>
</trans-unit>
<trans-unit id="25">
<source>This value is not valid</source>
<target>Значення недопустиме</target>
</trans-unit>
<trans-unit id="26">
<source>This value is not a valid time</source>
<target>Значення часу недопустиме</target>
</trans-unit>
<trans-unit id="27">
<source>This value is not a valid URL</source>
<target>Значення URL недопустиме</target>
</trans-unit>
<trans-unit id="28">
<source>This form should not contain extra fields</source>
<target>Ця форма не повинна містити додаткових полів</target>
</trans-unit>
<trans-unit id="29">
<source>The uploaded file was too large. Please try to upload a smaller file</source>
<target>Завантажений файл занадто великий. Будь-ласка, спробуйте завантажити файл меншого розміру</target>
</trans-unit>
<trans-unit id="30">
<source>The CSRF token is invalid. Please try to resubmit the form</source>
<target>CSRF значення недопустиме. Будь-ласка, спробуйте відправити форму знову</target>
</trans-unit>
<trans-unit id="31">
<source>The two values should be equal</source>
<target>Обидва занчення повинні бути одинаковими</target>
</trans-unit>
<trans-unit id="32">
<source>The file is too large. Allowed maximum size is {{ limit }}</source>
<target>Файл занадто великий. Максимальний допустимий розмір {{ limit }}</target>
</trans-unit>
<trans-unit id="33">
<source>The file is too large</source>
<target>Файл занадто великий</target>
</trans-unit>
<trans-unit id="34">
<source>The file could not be uploaded</source>
<target>Файл не можливо завантажити</target>
</trans-unit>
<trans-unit id="35">
<source>This value should be a valid number</source>
<target>Значення має бути допустимим числом</target>
</trans-unit>
<trans-unit id="36">
<source>This value is not a valid country</source>
<target>Значення не є допустимим значенням країни</target>
</trans-unit>
<trans-unit id="37">
<source>This file is not a valid image</source>
<target>Цей файл не є допустимим форматом зображення</target>
</trans-unit>
<trans-unit id="38">
<source>This is not a valid IP address</source>
<target>Значення не є допустимою IP адресою</target>
</trans-unit>
<trans-unit id="39">
<source>This value is not a valid language</source>
<target>Значення не є допустимим кодом мови</target>
</trans-unit>
</body>
</file>
</xliff>