X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FWebResponse.php;h=3a4faf0faa1f6846521198c03bfa57a8f982a0aa;hb=43fb6e8ddaee5d0d5293a772f2ce96b22e9a3427;hp=0e5999ddfbe5a445ffe612814a12e7cc35ffe188;hpb=56d45558b102349f3480a46819669407aa3be2d6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WebResponse.php b/includes/WebResponse.php index 0e5999ddfb..3a4faf0faa 100644 --- a/includes/WebResponse.php +++ b/includes/WebResponse.php @@ -151,21 +151,19 @@ class WebResponse { $expire = time() + $wgCookieExpiration; } - $cookie = $options['prefix'] . $name; - $data = [ - 'name' => (string)$cookie, - 'value' => (string)$value, - 'expire' => (int)$expire, - 'path' => (string)$options['path'], - 'domain' => (string)$options['domain'], - 'secure' => (bool)$options['secure'], - 'httpOnly' => (bool)$options['httpOnly'], - ]; - if ( self::$disableForPostSend ) { + $cookie = $options['prefix'] . $name; wfDebugLog( 'cookie', 'ignored post-send cookie {cookie}', 'all', [ 'cookie' => $cookie, - 'data' => $data, + 'data' => [ + 'name' => (string)$cookie, + 'value' => (string)$value, + 'expire' => (int)$expire, + 'path' => (string)$options['path'], + 'domain' => (string)$options['domain'], + 'secure' => (bool)$options['secure'], + 'httpOnly' => (bool)$options['httpOnly'], + ], 'exception' => new RuntimeException( 'Ignored post-send cookie' ), ] ); return; @@ -174,6 +172,19 @@ class WebResponse { $func = $options['raw'] ? 'setrawcookie' : 'setcookie'; if ( Hooks::run( 'WebResponseSetCookie', [ &$name, &$value, &$expire, &$options ] ) ) { + // Note: Don't try to move this earlier to reuse it for self::$disableForPostSend, + // we need to use the altered values from the hook here. (T198525) + $cookie = $options['prefix'] . $name; + $data = [ + 'name' => (string)$cookie, + 'value' => (string)$value, + 'expire' => (int)$expire, + 'path' => (string)$options['path'], + 'domain' => (string)$options['domain'], + 'secure' => (bool)$options['secure'], + 'httpOnly' => (bool)$options['httpOnly'], + ]; + // Per RFC 6265, key is name + domain + path $key = "{$data['name']}\n{$data['domain']}\n{$data['path']}";