Skip to content

Commit

Permalink
Merge branch '7.5' into 7.6
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed May 15, 2023
2 parents 733dd89 + 584d1f0 commit 8444a2b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Please refer to [UPGRADING](UPGRADING.md) guide for upgrading to a major version.

## 7.6.1 - 2023-05-15

### Fixed

- Fix `SetCookie::fromString` MaxAge deprecation warning and skip invalid MaxAge values

## 7.6.0 - 2023-05-14

### Added
Expand Down
8 changes: 7 additions & 1 deletion src/Cookie/SetCookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ public static function fromString(string $cookie): self
} else {
foreach (\array_keys(self::$defaults) as $search) {
if (!\strcasecmp($search, $key)) {
$data[$search] = $value;
if ($search === 'Max-Age') {
if (is_numeric($value)) {
$data[$search] = (int) $value;
}
} else {
$data[$search] = $value;
}
continue 2;
}
}
Expand Down
34 changes: 32 additions & 2 deletions tests/Cookie/SetCookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,44 @@ public function cookieParserDataProvider()
'Value' => 'synced',
'Domain' => '.example.com',
'Path' => '/',
'Expires' => \time() + 604800,
'Expires' => null,
'Secure' => true,
'Discard' => false,
'Max-Age' => 604800,
'Max-Age' => null,
'HttpOnly' => true,
'SameSite' => 'None',
],
],
[
'SESS3a6f27284c4d8b34b6f4ff98cb87703e=Ts-5YeSyvOCMS%2CzkEb9eDfW4C4ZNFOcRYdu-3JpEAXIm58aH; expires=Wed, 07-Jun-2023 15:56:35 GMT; Max-Age=2000000; path=/; domain=.example.com; HttpOnly; SameSite=Lax',
[
'Name' => 'SESS3a6f27284c4d8b34b6f4ff98cb87703e',
'Value' => 'Ts-5YeSyvOCMS%2CzkEb9eDfW4C4ZNFOcRYdu-3JpEAXIm58aH',
'Domain' => '.example.com',
'Path' => '/',
'Expires' => 'Wed, 07-Jun-2023 15:56:35 GMT',
'Secure' => false,
'Discard' => false,
'Max-Age' => 2000000,
'HttpOnly' => true,
'SameSite' => 'Lax',
],
],
[
'SESS3a6f27284c4d8b34b6f4ff98cb87703e=Ts-5YeSyvOCMS%2CzkEb9eDfW4C4ZNFOcRYdu-3JpEAXIm58aH; expires=Wed, 07-Jun-2023 15:56:35 GMT; Max-Age=qwerty; path=/; domain=.example.com; HttpOnly; SameSite=Lax',
[
'Name' => 'SESS3a6f27284c4d8b34b6f4ff98cb87703e',
'Value' => 'Ts-5YeSyvOCMS%2CzkEb9eDfW4C4ZNFOcRYdu-3JpEAXIm58aH',
'Domain' => '.example.com',
'Path' => '/',
'Expires' => 'Wed, 07-Jun-2023 15:56:35 GMT',
'Secure' => false,
'Discard' => false,
'Max-Age' => null,
'HttpOnly' => true,
'SameSite' => 'Lax',
],
],
];
}

Expand Down

0 comments on commit 8444a2b

Please sign in to comment.