Skip to content

Commit 8444a2b

Browse files
Merge branch '7.5' into 7.6
2 parents 733dd89 + 584d1f0 commit 8444a2b

3 files changed

Lines changed: 45 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

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

5+
## 7.6.1 - 2023-05-15
6+
7+
### Fixed
8+
9+
- Fix `SetCookie::fromString` MaxAge deprecation warning and skip invalid MaxAge values
10+
511
## 7.6.0 - 2023-05-14
612

713
### Added

src/Cookie/SetCookie.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,13 @@ public static function fromString(string $cookie): self
5858
} else {
5959
foreach (\array_keys(self::$defaults) as $search) {
6060
if (!\strcasecmp($search, $key)) {
61-
$data[$search] = $value;
61+
if ($search === 'Max-Age') {
62+
if (is_numeric($value)) {
63+
$data[$search] = (int) $value;
64+
}
65+
} else {
66+
$data[$search] = $value;
67+
}
6268
continue 2;
6369
}
6470
}

tests/Cookie/SetCookieTest.php

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,44 @@ public function cookieParserDataProvider()
367367
'Value' => 'synced',
368368
'Domain' => '.example.com',
369369
'Path' => '/',
370-
'Expires' => \time() + 604800,
370+
'Expires' => null,
371371
'Secure' => true,
372372
'Discard' => false,
373-
'Max-Age' => 604800,
373+
'Max-Age' => null,
374374
'HttpOnly' => true,
375375
'SameSite' => 'None',
376376
],
377377
],
378+
[
379+
'SESS3a6f27284c4d8b34b6f4ff98cb87703e=Ts-5YeSyvOCMS%2CzkEb9eDfW4C4ZNFOcRYdu-3JpEAXIm58aH; expires=Wed, 07-Jun-2023 15:56:35 GMT; Max-Age=2000000; path=/; domain=.example.com; HttpOnly; SameSite=Lax',
380+
[
381+
'Name' => 'SESS3a6f27284c4d8b34b6f4ff98cb87703e',
382+
'Value' => 'Ts-5YeSyvOCMS%2CzkEb9eDfW4C4ZNFOcRYdu-3JpEAXIm58aH',
383+
'Domain' => '.example.com',
384+
'Path' => '/',
385+
'Expires' => 'Wed, 07-Jun-2023 15:56:35 GMT',
386+
'Secure' => false,
387+
'Discard' => false,
388+
'Max-Age' => 2000000,
389+
'HttpOnly' => true,
390+
'SameSite' => 'Lax',
391+
],
392+
],
393+
[
394+
'SESS3a6f27284c4d8b34b6f4ff98cb87703e=Ts-5YeSyvOCMS%2CzkEb9eDfW4C4ZNFOcRYdu-3JpEAXIm58aH; expires=Wed, 07-Jun-2023 15:56:35 GMT; Max-Age=qwerty; path=/; domain=.example.com; HttpOnly; SameSite=Lax',
395+
[
396+
'Name' => 'SESS3a6f27284c4d8b34b6f4ff98cb87703e',
397+
'Value' => 'Ts-5YeSyvOCMS%2CzkEb9eDfW4C4ZNFOcRYdu-3JpEAXIm58aH',
398+
'Domain' => '.example.com',
399+
'Path' => '/',
400+
'Expires' => 'Wed, 07-Jun-2023 15:56:35 GMT',
401+
'Secure' => false,
402+
'Discard' => false,
403+
'Max-Age' => null,
404+
'HttpOnly' => true,
405+
'SameSite' => 'Lax',
406+
],
407+
],
378408
];
379409
}
380410

0 commit comments

Comments
 (0)