SetCookie::getFieldValue() always uses urlencode() for cookie values, even in case they are already encoded #2929

Merged
merged 2 commits into from Nov 14, 2012

2 participants

@Maks3w Maks3w and 1 other commented on an outdated diff Nov 9, 2012
library/Zend/Http/Header/SetCookie.php
@@ -230,7 +230,7 @@ public function getFieldValue()
if (strpos($value, '"')!==false) {
$value = '"'.urlencode(str_replace('"', '', $value)).'"';
} else {
- $value = urlencode($value);
+ $value = urlencode(urldecode($value));
@Maks3w
Zend Framework member
Maks3w added a line comment Nov 9, 2012

This sounds like X - Y + Y = X

@postalservice14
postalservice14 added a line comment Nov 9, 2012

:-) It is.... I couldn't think of another way to detect if the $value was already encoded or not. Doing this will make it so the $value isn't encoded twice.

@Maks3w
Zend Framework member
Maks3w added a line comment Nov 9, 2012

urldecode is part of the task needed to transform the raw input into PHP values. So the correct place for call this function may be fromString() or setValue()

I suggest do this before call setValue inside fromString method at line 112 $header->setValue($headerValue);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@postalservice14

@Maks3w thanks, good suggestion.

@Maks3w Maks3w closed this Nov 9, 2012
@Maks3w Maks3w reopened this Nov 9, 2012
@Maks3w Maks3w closed this Nov 14, 2012
@Maks3w Maks3w reopened this Nov 14, 2012
@Maks3w Maks3w was assigned Nov 14, 2012
@Maks3w Maks3w added a commit that referenced this pull request Nov 14, 2012
@Maks3w Maks3w Forward port #2929 8a1305b
@Maks3w Maks3w merged commit c67be6b into zendframework:master Nov 14, 2012

1 check failed

Details default The Travis build failed
@ghost Unknown pushed a commit that referenced this pull request Jul 14, 2013
@Maks3w Maks3w Forward port #2929 91e7eca
@gianarb gianarb pushed a commit to zendframework/zend-http that referenced this pull request May 15, 2015
@Maks3w Maks3w Merge pull request zendframework/zendframework#2929 branch 'hotfix/fi…
…x-double-cookie-encoding' Close zendframework/zendframework#2444
e193ac7
@gianarb gianarb pushed a commit to zendframework/zend-http that referenced this pull request May 15, 2015
@Maks3w Maks3w Forward port zendframework/zendframework#2929 c3c240a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment