Skip to content

[Forwardport] ISSUE-14109: Allow modification of cookies via extension #14366

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

Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@ private function checkAbilityToSendCookie($name, $value)

$sizeOfCookie = $this->sizeOfCookie($name, $value);

if ($numCookies > PhpCookieManager::MAX_NUM_COOKIES) {
if ($numCookies > static::MAX_NUM_COOKIES) {
$this->logger->warning(
new Phrase('Unable to send the cookie. Maximum number of cookies would be exceeded.'),
array_merge($_COOKIE, ['user-agent' => $this->httpHeader->getHttpUserAgent()])
);
}

if ($sizeOfCookie > PhpCookieManager::MAX_COOKIE_SIZE) {
if ($sizeOfCookie > static::MAX_COOKIE_SIZE) {
throw new CookieSizeLimitReachedException(
new Phrase(
'Unable to send the cookie. Size of \'%name\' is %size bytes.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class PhpCookieManagerTest extends \PHPUnit\Framework\TestCase
const COOKIE_HTTP_ONLY = true;
const COOKIE_NOT_HTTP_ONLY = false;
const COOKIE_EXPIRE_END_OF_SESSION = 0;
const MAX_NUM_COOKIES = 50;
const MAX_COOKIE_SIZE = 4096;

/**
* Mapping from constant names to functions that handle the assertions.
Expand Down Expand Up @@ -499,7 +497,9 @@ public function testSetCookieSizeTooLarge()
);

$cookieValue = '';
for ($i = 0; $i < self::MAX_COOKIE_SIZE + 1; $i++) {

$cookieManager = $this->cookieManager;
for ($i = 0; $i < $cookieManager::MAX_COOKIE_SIZE + 1; $i++) {
$cookieValue = $cookieValue . 'a';
}

Expand Down Expand Up @@ -527,8 +527,9 @@ public function testSetTooManyCookies()

$userAgent = 'some_user_agent';

// Set self::MAX_NUM_COOKIES number of cookies in superglobal $_COOKIE.
for ($i = count($_COOKIE); $i < self::MAX_NUM_COOKIES; $i++) {
$cookieManager = $this->cookieManager;
// Set $cookieManager::MAX_NUM_COOKIES number of cookies in superglobal $_COOKIE.
for ($i = count($_COOKIE); $i < $cookieManager::MAX_NUM_COOKIES; $i++) {
$_COOKIE['test_cookie_' . $i] = self::COOKIE_VALUE . '_' . $i;
}

Expand Down