@@ -439,9 +439,19 @@ public function setCookie($name, $value = null)
439439 return ;
440440 }
441441
442+ // PHP 7.4 changed the way it encodes cookies to better respect the spec.
443+ // This assumes that the server and the Mink client run on the same version (or
444+ // at least the same side of the behavior change), so that the server and Mink
445+ // consider the same value.
446+ if (\PHP_VERSION_ID >= 70400 ) {
447+ $ encodedValue = rawurlencode ($ value );
448+ } else {
449+ $ encodedValue = urlencode ($ value );
450+ }
451+
442452 $ cookieArray = array (
443453 'name ' => $ name ,
444- 'value ' => urlencode ( $ value ) ,
454+ 'value ' => $ encodedValue ,
445455 'secure ' => false , // thanks, chibimagic!
446456 );
447457
@@ -456,6 +466,14 @@ public function getCookie($name)
456466 $ cookies = $ this ->wdSession ->getAllCookies ();
457467 foreach ($ cookies as $ cookie ) {
458468 if ($ cookie ['name ' ] === $ name ) {
469+ // PHP 7.4 changed the way it encodes cookies to better respect the spec.
470+ // This assumes that the server and the Mink client run on the same version (or
471+ // at least the same side of the behavior change), so that the server and Mink
472+ // consider the same value.
473+ if (\PHP_VERSION_ID >= 70400 ) {
474+ return rawurldecode ($ cookie ['value ' ]);
475+ }
476+
459477 return urldecode ($ cookie ['value ' ]);
460478 }
461479 }
0 commit comments