Skip to content
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

fix: Check if cookies are iterable before iterating #356

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/Selenium2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,17 +462,19 @@ public function setCookie($name, $value = null)
public function getCookie($name)
{
$cookies = $this->wdSession->getAllCookies();
foreach ($cookies as $cookie) {
if ($cookie['name'] === $name) {
// PHP 7.4 changed the way it encodes cookies to better respect the spec.
// This assumes that the server and the Mink client run on the same version (or
// at least the same side of the behavior change), so that the server and Mink
// consider the same value.
if (\PHP_VERSION_ID >= 70400) {
return rawurldecode($cookie['value']);
if (is_iterable($cookies)) {
foreach ($cookies as $cookie) {
if ($cookie['name'] === $name) {
// PHP 7.4 changed the way it encodes cookies to better respect the spec.
// This assumes that the server and the Mink client run on the same version (or
// at least the same side of the behavior change), so that the server and Mink
// consider the same value.
if (\PHP_VERSION_ID >= 70400) {
return rawurldecode($cookie['value']);
}

return urldecode($cookie['value']);
}

return urldecode($cookie['value']);
}
}
}
Expand Down