Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Use rawurlencode() to transform the Cookie into a string #23461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

javiereguiluz
Copy link
Member

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #23255
License MIT
Doc PR -

@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Jul 10, 2017
@nicolas-grekas
Copy link
Member

Cookie in BrowserKit has the same issue isn't it?

@javiereguiluz
Copy link
Member Author

javiereguiluz commented Jul 10, 2017

@nicolas-grekas I've made that change too. However, when copying the testToString() test from HttpFoundation, I needed to fix all tests because the results are pretty different from the HttpFoundation tests. Are those differences expected?

Examples:

$cookie = new Cookie('foo', 'bar', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true);

// in HttpFoundation
(string) $cookie = 'foo=bar; expires=Fri, 20 May 2011 15:25:52 GMT; domain=.myfoodomain.com; path=/; secure; httponly'

// in BrowserKit
(string) $cookie = 'foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; path=/; domain=.myfoodomain.com; secure; httponly'
$cookie = new Cookie('foo', 'bar', 0, '/', '');

// in HttpFoundation
(string) $cookie = 'foo=bar; path=/; httponly'

// in BrowserKit
(string) $cookie = 'foo=bar; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; httponly'

@@ -58,11 +58,11 @@ class Cookie
public function __construct($name, $value, $expires = null, $path = null, $domain = '', $secure = false, $httponly = true, $encodedValue = false)
{
if ($encodedValue) {
$this->value = urldecode($value);
$this->value = rawurldecode($value);
Copy link
Contributor

@ro0NL ro0NL Jul 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we update decoding, Cookie::fromString in HttpFoundation should probably be updated as well, note however urldecode works for rawurlencode perfectly fine, so im not sure we should change it (given rawurldecode doesnt work for urlencode).

Copy link
Member

@nicolas-grekas nicolas-grekas Jul 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me, we can keep urldecode here

@stof
Copy link
Member

stof commented Jul 10, 2017

@javiereguiluz your first example outputs the same cookie. Attributes are just given in a different order. But order is not meaningful.

@javiereguiluz
Copy link
Member Author

@stof yes, the first example is the same, but with a different ordering. But I think it should be exactly the same. The attention a project pays to details like this says a lot about a project 😄

@nicolas-grekas
Copy link
Member

Thank you @javiereguiluz.

nicolas-grekas added a commit that referenced this pull request Jul 11, 2017
…javiereguiluz)

This PR was squashed before being merged into the 2.7 branch (closes #23461).

Discussion
----------

Use rawurlencode() to transform the Cookie into a string

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23255
| License       | MIT
| Doc PR        | -

Commits
-------

025dfff Use rawurlencode() to transform the Cookie into a string
@fabpot fabpot closed this Jul 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.