-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Disallow invalid characters in session.name #27246
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
10cbf6c
to
1548744
Compare
Good idea. |
Not sure what do you mean. Can you be more specific? Should I change this validation approach to just normalization approach? Frankly, I would like that more, so I don't have to do that by myself in userspace. Some cases are also handled internally by php's
|
Instead of checking for some chars (there are more that are turned to an underscore), I was thinking about doing the check like this: |
|
||
return implode('&', array_keys($parsed)) !== (string) $v; | ||
}) | ||
->thenInvalid('Session name %s contains illegal character(s)') |
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.
missing double quotes around %s
about the implode, this means &
is valid in a session name? how strange is that :)
but OK, that's because cookie are not encoded using URL queries.
This also means we should exclude ;
, isn't it?
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.
Config quotes it by type itself, if I did it, it would be double quoted. Yes, & is valid. No need to exclude ;
and further complicate this closure, rest of the chars are handled by setcookie call. As long as developer is warned, it's all good.
Got any pointers why appveyor fails?
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.
Appveryor fails for some reason on '
char even though it's valid... I've just removed it from test case
abc19c2
to
56646ad
Compare
PHP saves cookie with correct name, but upon deserialization to $_COOKIE, it replaces some characters, e.g. "." becomes "_". This is probably also reason why \SessionHandler is not able to find a session. https://harrybailey.com/2009/04/dots-arent-allowed-in-php-cookie-names/ https://bugs.php.net/bug.php?id=75883
56646ad
to
16ebb43
Compare
Thank you @ostrolucky. |
This PR was merged into the 2.7 branch. Discussion ---------- Disallow invalid characters in session.name | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27023 | License | MIT | Doc PR | PHP saves cookie with correct name, but upon deserialization to `$_COOKIE`, it replaces "." characters with "_". This is probably also reason why \SessionHandler is not able to find a session. https://harrybailey.com/2009/04/dots-arent-allowed-in-php-cookie-names/ https://bugs.php.net/bug.php?id=75883 Commits ------- 16ebb43 Disallow illegal characters like "." in session.name
PHP saves cookie with correct name, but upon deserialization to
$_COOKIE
, it replaces "." characters with "_".This is probably also reason why \SessionHandler is not able to find
a session.
https://harrybailey.com/2009/04/dots-arent-allowed-in-php-cookie-names/
https://bugs.php.net/bug.php?id=75883