-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Conversation
javiereguiluz
commented
Jul 9, 2017
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 | - |
Cookie in BrowserKit has the same issue isn't it? |
@nicolas-grekas I've made that change too. However, when copying the 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); |
There was a problem hiding this comment.
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
).
There was a problem hiding this comment.
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
@javiereguiluz your first example outputs the same cookie. Attributes are just given in a different order. But order is not meaningful. |
@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 😄 |
Thank you @javiereguiluz. |
…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