Commit Graph

9092 Commits

Author SHA1 Message Date
Bernhard Schussek 2e07256921 [Form] Simplified choice list API 2012-04-10 15:37:24 +02:00
Bernhard Schussek 26451201e0 [Form] Fixed handling of expanded choice lists, checkboxes and radio buttons with empty values ("") 2012-04-10 15:35:46 +02:00
Fabien Potencier 07e261ea9e removed obsolete files 2012-04-10 11:50:32 +02:00
Fabien Potencier a8cfa4a7de merged branch pminnieur/patch-2 (PR #3852)
Commits
-------

a56bea6 removed `param_converter` from symfony-1.0.xsd

Discussion
----------

removed `param_converter` from symfony-1.0.xsd

I think its a relict of the SensioFrameworkExtraBundle?
2012-04-10 11:13:14 +02:00
Pierre Minnieur a56bea6d88 removed `param_converter` from symfony-1.0.xsd 2012-04-10 12:00:57 +03:00
Fabien Potencier 8860424823 merged branch vicb/url_decoding (PR #3780)
Commits
-------

55014a6 [Routing] Request methods always return a raw path, fix the matcher to decode only once
d17ba0e Fixed base URL detection when request URI contains encoded chars

Discussion
----------

[RFC] Fix issues with url decoding

Related: #2324, #2963, #2962, #2579

### This PR fixes two issues:

* `+` in paths were turned to " " by `urldecode()`
* `urldecode()` was called a few times (and a different number of times according to which part of the path was handled, see #2962 for details).

### BC Breaks:

* `Request::getPathInfo()`, `Request::getBaseUrl()` and `Request::getBasePath` now return the raw (encoded) path (vs a decoded path before this PR). You should check any calls to these methods in your code and wrap them in `rawurldecode()` if needed.
* The `UrlMatcher` now decodes the URL only once (i.e. variable are no more decoded twice) and use `rawurldecode()` to support `+`.

### Notes:

* @arnaud-lb, the first commit is based on your #2963 so I put your name for the commit,

### Comment history from the original PR:

@vicb

**The state before this PR:**

* getRequestUri() returns an **encoded** value
* getPathInfo() returns a **decoded** value
* getBaseUrl() returns a **decoded** value
* getBasePath() returns a **decoded** value

The decoded value is wrong as `urldecode` is used in place of `rawurldecode` turning `+` into a space character (#2324).

The matcher starts by urldecoing the path (it is already decoded as explained right before) and then urldecodes each variable one more time.

We end up with a path being decoded twice and variables being decoded three times.

`Request::getUri()` calls both `getBaseUrl()` and `getPathInfo()` so that the return URI is **decoded**.

**The state after the PR:**

* getRequestUri() returns an **encoded** value
* getPathInfo() returns an **encoded** value
* getBaseUrl() returns an **encoded** value
* getBasePath() returns an **encoded** value

We are consistent and we have the raw values everywhere - there is no (easy) way to get the encoded value back once it has been decoded as it is done in the current code.

The matcher relies on an encoded value and decode the value only once (using `rawurldecode` to support `+`s).

So basically this PR:

* fix a bug - URL with `+` are now supported,
* makes paths consistent - encoded values everywhere, including `getUri()`
* makes variables consistent: they are decoded only once - the same as query string parameters.

There are some BC breaks:

* getPathInfo() returns an encoded value vs a decoded one before,
* getBaseUrl() returns an encoded value vs a decoded one before.
* getBasePath() returns an encoded value vs a decoded one before.

Any code relying on the output of one of the 2 previous methods should be checked and upgraded if needed. I am interested in the use cases where your code need to be updated.

@Seldaek

I checked a few projects and this is what I found (usage of getPathInfo & getBaseUrl):

- One use case of getPathInfo to check if the url started with `/something/` which is a prefix used for all "overlay" content which had to be treated differently somewhere => most likely unaffected
- One use case for checking path prefixes by regex in our [CorsBundle](https://github.com/nelmio/NelmioCorsBundle/blob/master/EventListener/CorsListener.php#L52-56) => potentially affected depending on the complexity of regexes I'd say

@vicb

Thanks @Seldaek for reporting the use cases. You second case would be solved by `rawurldecode`ing the path info which is a minimal change.

And in general I think we have to expand to doc to specify the url format that should be used.

---------------------------------------------------------------------------

by vicb at 2012-04-04T13:42:21Z

I'll squash the commits before this gets merged but for now it make the review easier.
2012-04-10 10:43:27 +02:00
Victor Berchet 55014a6841 [Routing] Request methods always return a raw path, fix the matcher to decode only once
sq
2012-04-10 10:40:58 +02:00
Fabien Potencier 2a16f84ce5 merged branch alessandro1997/issue-3848 (PR #3849)
Commits
-------

78d6f3f [Filesystem] Written missing tests.
1998f3f [Filesystem] Added silence operator to rename().
7ce5a52 [Filesystem] Fixed docs for rename().
3f2865b [Filesystem] rename() throws RuntimeException on error (fixes #3848).

Discussion
----------

[Filesystem] rename() throws RuntimeException on error.

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #3848

---------------------------------------------------------------------------

by alessandro1997 at 2012-04-09T19:32:23Z

I have a doubt: I can't write any tests since the rename() function generates a warning if an error occurs. Should I use the silence operator or what else?

Maybe @stof could enlighten me?
2012-04-10 10:27:05 +02:00
Arnaud Le Blanc d17ba0e147 Fixed base URL detection when request URI contains encoded chars
Signed-off-by: Victor Berchet <victor@suumit.com>
2012-04-10 10:15:43 +02:00
Alessandro Desantis 78d6f3f0e0 [Filesystem] Written missing tests. 2012-04-10 10:15:30 +02:00
Alessandro Desantis 1998f3f5ec [Filesystem] Added silence operator to rename(). 2012-04-10 10:15:18 +02:00
Alessandro Desantis 7ce5a526ec [Filesystem] Fixed docs for rename(). 2012-04-09 21:19:37 +02:00
Alessandro Desantis 3f2865b90f [Filesystem] rename() throws RuntimeException on error (fixes #3848). 2012-04-09 20:56:50 +02:00
Fabien Potencier 127cff0aa8 merged branch Seldaek/process_fix (PR #3838)
Commits
-------

6dca141 [Process] Skip signal assertion on windows
4cd0fb4 [Process] Skip test that is still getting stuck on windows
e82a05d [Process] Close pipes before calling proc_close to avoid deadlocks as advised on the proc_close php.net documentation
f4227b5 [Process] Removing useless code (this is already done in updateStatus)
2d586d2 [Process] Fix a mistake triggering stream_select errors

Discussion
----------

Process fixes

A few fixes, including making the tests pass on windows and fixing composer/composer#543. Given the sensitivity of this code I did a bunch of very granular commits explaining everything.
2012-04-08 20:44:36 +02:00
Jordi Boggiano 6dca141de8 [Process] Skip signal assertion on windows 2012-04-08 20:29:02 +02:00
Jordi Boggiano 4cd0fb4c69 [Process] Skip test that is still getting stuck on windows 2012-04-08 20:28:28 +02:00
Jordi Boggiano e82a05d3e7 [Process] Close pipes before calling proc_close to avoid deadlocks as advised on the proc_close php.net documentation 2012-04-08 20:27:37 +02:00
Jordi Boggiano f4227b5f82 [Process] Removing useless code (this is already done in updateStatus) 2012-04-08 20:26:27 +02:00
Jordi Boggiano 2d586d245d [Process] Fix a mistake triggering stream_select errors 2012-04-08 20:26:04 +02:00
Fabien Potencier d6948581ac [TwigBundle] simplified code 2012-04-08 12:56:21 +02:00
Fabien Potencier a11ec3e71c [TwigBundle] added correct file name in twig:lint exception reporting 2012-04-08 12:53:40 +02:00
Fabien Potencier 57c6aaa397 [TwigBundle] tweaked previous merge 2012-04-08 12:41:50 +02:00
Fabien Potencier 9c0fba93b2 merged branch marcw/feat-twig-lint (PR #3804)
Commits
-------

8726ade Adds more features to twig:lint command
1d7e9d9 Adds a linter command for templates

Discussion
----------

Adds a linter command for templates

Let's this PR be stoffed. ;)

---------------------------------------------------------------------------

by Tobion at 2012-04-06T15:48:18Z

Checking a single file is very limited. Checking a whole directory would be more useful, wouldn't it?

---------------------------------------------------------------------------

by willdurand at 2012-04-06T17:56:57Z

I think you should provide a way to validate all templates for a given bundle, something like:

    php app/console twig:lint @MySuperBundle

---------------------------------------------------------------------------

by henrikbjorn at 2012-04-06T18:03:45Z

Wouldnt it be better to throw some kind of exception if the lint is erroneous?

---------------------------------------------------------------------------

by marcw at 2012-04-07T11:22:34Z

@Tobion @willdurand  You can do that by combining unix tools.
@henrikbjorn Why ?

---------------------------------------------------------------------------

by marcw at 2012-04-07T11:27:11Z

Updated.

---------------------------------------------------------------------------

by dlsniper at 2012-04-07T13:15:53Z

@marcw it would be indeed nice to have support for a bundle/directory out of the box as some of the Symfony2 users might not be running unix or know the right commands to make this work.

I could help you with a PR in your repo if you want.

---------------------------------------------------------------------------

by henrikbjorn at 2012-04-07T18:55:34Z

@marcw as the console component will catch them and convert them into the right error code, also will display what went wrong instead of just dieing.

---------------------------------------------------------------------------

by marcw at 2012-04-08T09:15:37Z

Updated with all comments and requested features.
2012-04-08 12:39:25 +02:00
marc.weistroff 8726ade310 Adds more features to twig:lint command 2012-04-08 11:14:51 +02:00
Fabien Potencier 5122d68c24 merged branch ruimarinho/exception_css_tweaks (PR #3827)
Commits
-------

fad114b Tweaked the exceptions layout CSS in order to display the error message even when wrapped around <pre> tags

Discussion
----------

Tweaked the exceptions layout CSS in order to display the error message even when wrapped around <pre> tags

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: ![Build status](https://secure.travis-ci.org/ruimarinho/symfony.png?branch=exception_css_tweaks)
Fixes the following tickets: -
Todo: -

Ever been in a situation when you're debugging code wrapped around `<pre>` tags and that code throws an exception? If you're familiar with this screenshot, you have :-) ![Image](http://i.imgur.com/dwxdD.png)

This PR is just a little tweak to the exceptions layout CSS in order to allow your to view the exception message. It also fixes a word break when messages are too long. ![Image 2](http://i.imgur.com/whxZv.png).

The build is currently failing due to an unmerged patch from the 2.0 branch.
2012-04-08 09:24:17 +02:00
Fabien Potencier 0e525fc5ce merged 2.0 2012-04-08 09:22:35 +02:00
Fabien Potencier c6096e323e merged branch eriksencosta/test-fixes (PR #3830)
Commits
-------

fdee352 [TwigBridge] updated suggested packages
dad1750 [TwigBridge] updated TestCase as an abstract class
140ac20 [TwigBridge] fixed bootstrap

Discussion
----------

[TwigBridge] updated Composer suggested packages and test fixes

---------------------------------------------------------------------------

by eriksencosta at 2012-04-08T06:13:53Z

Rebased.
2012-04-08 09:18:17 +02:00
Fabien Potencier bca8c5feac merged branch jakzal/FilesystemBugFix (PR #3828)
Commits
-------

22e2ad8 [Filesystem] Fixed relative path calculation for end path which is a subdirectory of the start path.
bc93787 [Filesystem] Fixed relative path calculation for paths with various combinations of trailing directory separators.

Discussion
----------

[Filesystem] Fixed relative path calculation

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
2012-04-08 09:16:07 +02:00
Eriksen Costa fdee352619 [TwigBridge] updated suggested packages 2012-04-08 03:12:14 -03:00
Eriksen Costa dad1750dfa [TwigBridge] updated TestCase as an abstract class 2012-04-07 18:49:17 -03:00
Eriksen Costa 140ac2014e [TwigBridge] fixed bootstrap 2012-04-07 18:47:00 -03:00
Jakub Zalas 22e2ad80c9 [Filesystem] Fixed relative path calculation for end path which is a subdirectory of the start path. 2012-04-07 21:52:26 +01:00
Jakub Zalas bc93787a0d [Filesystem] Fixed relative path calculation for paths with various combinations of trailing directory separators. 2012-04-07 21:19:12 +01:00
Fabien Potencier dee79e910d merged branch jakzal/SetCookieWithMultipleCookiesBugFix (PR #3823)
Commits
-------

7f92833 [BrowserKit] Fixed cs.
df3da28 [BrowserKit] Using assertNull instead of assertEquals.
87890d3 [BrowserKit] Fixed CookieJar issue being unable to parse multiple cookies from Set-Cookie.

Discussion
----------

[BrowserKit] Fixed CookieJar being unable to parse multiple cookies

Fix proposition for #3109

My fix splits value of *Set-Cookie* header by comma. Than it checks each extracted part if it starts with a cookie-name (token). If check is positive cookie is added to the list. Otherwise it's appended to the previous value. First element is always added to the list.

[rfc6265](http://tools.ietf.org/html/rfc6265) defines cookie-name with token:

    cookie-name = token
    token = <token, defined in [RFC2616], Section 2.2>

token is defined in [rfc2616](http://tools.ietf.org/html/rfc2616#section-2.2) as follows:

    token = 1*<any CHAR except CTLs or separators>
    CHAR = <any US-ASCII character (octets 0 - 127)>
    separators = "(" | ")" | "<" | ">" | "@"
                  | "," | ";" | ":" | "\" | <">
                  | "/" | "[" | "]" | "?" | "="
                  | "{" | "}" | SP | HT

That means cookie-name can be built out of following set of characters: *! # $ % & ' * + - . ^ _ ` | ~ 0-9 A-Z a-z*

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
2012-04-07 21:57:48 +02:00
Jakub Zalas 7f928332a9 [BrowserKit] Fixed cs. 2012-04-07 19:45:50 +01:00
Fabien Potencier 0a7f4668e0 [Process] added a note about user-defined error exist codes 2012-04-07 20:15:50 +02:00
Fabien Potencier 34b1b6b17d merged branch bschussek/issue3661 (PR #3821)
Commits
-------

e0ce6b4 [Form] Fixed required value guessed by ValidatorTypeGuesser

Discussion
----------

[Form] Fixed required value guessed by ValidatorTypeGuesser

Bug fix: yes
Feature addition: no
Backwards compatibility break: no*
Symfony2 tests pass: yes
Fixes the following tickets: #3661
Todo: -

![Travis Build Status](https://secure.travis-ci.org/bschussek/symfony.png?branch=issue3661)

The documentation states that a field is set to required if constrained with NotBlank or NotNull and to not required otherwise. Due to a bug this was not the case and fields were always required. This is now fixed.

The consequence is that some fields that were required before by default are not required anymore. The only difference is that the HTML5 "required" attribute disappears, because server-side validation did not occur before anyway.
2012-04-07 20:06:18 +02:00
Jakub Zalas df3da289ad [BrowserKit] Using assertNull instead of assertEquals. 2012-04-07 18:45:48 +01:00
Jakub Zalas 87890d3a7c [BrowserKit] Fixed CookieJar issue being unable to parse multiple cookies from Set-Cookie. 2012-04-07 18:38:39 +01:00
Rui Marinho fad114b76a Tweaked the exceptions layout CSS in order to display the error message even when wrapped around <pre> tags 2012-04-07 16:28:29 +01:00
Bernhard Schussek e0ce6b4c11 [Form] Fixed required value guessed by ValidatorTypeGuesser 2012-04-07 16:26:16 +02:00
marc.weistroff 1d7e9d9753 Adds a linter command for templates 2012-04-07 13:26:03 +02:00
Fabien Potencier 13aa515d65 merged branch jakzal/FilesystemTests (PR #3811)
Commits
-------

100e97e [Filesystem] Fixed warnings in makePathRelative().
f5f5c21 [Filesystem] Fixed typos in the docblocks.
d4243a2 [Filesystem] Fixed a bug in remove being unable to remove symlinks to unexisting file or directory.
11a676d [Filesystem] Added unit tests for mirror method.
8c94069 [Filesystem] Added unit tests for isAbsolutePath method.
2ee4b88 [Filesystem] Added unit tests for makePathRelative method.
21860cb [Filesystem] Added unit tests for symlink method.
a041feb [Filesystem] Added unit tests for rename method.
8071859 [Filesystem] Added unit tests for chmod method.
bba0080 [Filesystem] Added unit tests for remove method.
8e861b7 [Filesystem] Introduced workspace directory to limit complexity of tests.
a91e200 [Filesystem] Added unit tests for touch method.
7e297db [Filesystem] Added unit tests for mkdir method.
6ac5486 [Filesystem] Added unit tests for copy method.
1c833e7 [Filesystem] Added missing docblock comment.

Discussion
----------

[Filesystem] Fixed a bug in remove() being unable to unlink broken symlinks

While working on test coverage for Filesystem class I discovered a bug in remove() method.

Before removing a file a check is made if it exists:

    if (!file_exists($file)) {
        continue;
    }

Problem is [file_exists()](http://php.net/file_exists) returns false if link's target file doesn't exist. Therefore remove() will fail to delete a directory containing a broken link. Solution is to handle links a bit different:

    if (!file_exists($file) && !is_link($file)) {
        continue;
    }

Additionally, this PR improves test coverage of Filesystem component.

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes

---------------------------------------------------------------------------

by cordoval at 2012-04-07T00:55:59Z

✌.|•͡˘‿•͡˘|.✌

---------------------------------------------------------------------------

by fabpot at 2012-04-07T06:12:34Z

Tests do not pass for me:

    PHPUnit 3.6.10 by Sebastian Bergmann.

    Configuration read from /Users/fabien/work/symfony/git/symfony/phpunit.xml.dist

    .........................EE.......

    Time: 0 seconds, Memory: 5.25Mb

    There were 2 errors:

    1) Symfony\Component\Filesystem\Tests\FilesystemTest::testMakePathRelative with data set #0 ('/var/lib/symfony/src/Symfony/', '/var/lib/symfony/src/Symfony/Component', '../')
    Uninitialized string offset: 29

    .../rc/Symfony/Component/Filesystem/Filesystem.php:183
    .../rc/Symfony/Component/Filesystem/Tests/FilesystemTest.php:434

    2) Symfony\Component\Filesystem\Tests\FilesystemTest::testMakePathRelative with data set #1 ('var/lib/symfony/', 'var/lib/symfony/src/Symfony/Component', '../../../')
    Uninitialized string offset: 16

    .../rc/Symfony/Component/Filesystem/Filesystem.php:183
    .../rc/Symfony/Component/Filesystem/Tests/FilesystemTest.php:434

    FAILURES!
    Tests: 34, Assertions: 67, Errors: 2.

---------------------------------------------------------------------------

by jakzal at 2012-04-07T07:26:15Z

Sorry for this. For some reason my PHP error reporting level was to low to catch this...

Should be fixed now but I needed to modify the makePathRelative() (this bug existed before).
2012-04-07 10:18:55 +02:00
Fabien Potencier e7dbc38941 merged branch eriksencosta/pt_BR-translations (PR #3817)
Commits
-------

bf51a58 [FrameworkBundle] fixed pt_BR translations (added commas to take a breath :)
dc94e27 [FrameworkBundle] synced pt_BR translations

Discussion
----------

synced and fixed pt_BR translations
2012-04-07 10:18:49 +02:00
Eriksen Costa bf51a58f37 [FrameworkBundle] fixed pt_BR translations (added commas to take a breath :) 2012-04-07 04:30:12 -03:00
Eriksen Costa dc94e27dbb [FrameworkBundle] synced pt_BR translations 2012-04-07 04:29:23 -03:00
Jakub Zalas 100e97ebe7 [Filesystem] Fixed warnings in makePathRelative(). 2012-04-07 08:23:20 +01:00
Fabien Potencier 72e854e943 fixed CS 2012-04-07 09:10:50 +02:00
Fabien Potencier 0a585b7130 merged branch eriksencosta/cs-fixes (PR #3816)
Commits
-------

abd59c3 Merge branch 'master' into cs-fixes
f5f0506 [TwigBundle] fixed CS

Discussion
----------

CS fixes
2012-04-07 09:04:09 +02:00
Eriksen Costa abd59c3dbd Merge branch 'master' into cs-fixes 2012-04-07 03:53:28 -03:00