Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

fixes case sensitivity for SameSite directive #207

Conversation

wilcol
Copy link
Contributor

@wilcol wilcol commented Dec 30, 2019

This fix handles case sensitivity for SameSite directive in cookie headers.

Prior to this fix the SameSite values were case sensitive compared with their capitalized names (Lax, Strict, None). This fix allows for case insensitive comparison, allowing values like lax and LAX.

See #206 for more information

Copy link
Member

@michalbundyra michalbundyra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wilcol Thanks for your contribution. I have couple minor comments. In general it looks good. See my comments below. Thanks!

src/Header/SetCookie.php Outdated Show resolved Hide resolved
src/Header/SetCookie.php Outdated Show resolved Hide resolved
src/Header/SetCookie.php Outdated Show resolved Hide resolved
test/Header/SetCookieTest.php Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@wilcol
Copy link
Contributor Author

wilcol commented Dec 30, 2019

@michalbundyra, I processed your feedback. Thank you.

src/Header/SetCookie.php Outdated Show resolved Hide resolved
@wilcol
Copy link
Contributor Author

wilcol commented Dec 30, 2019

@Xerkus, I processed your feedback.

src/Header/SetCookie.php Outdated Show resolved Hide resolved
@Xerkus
Copy link
Member

Xerkus commented Dec 30, 2019

Please also add a separate test for asserting that SameSite value is canonicalized in setSameSite

@wilcol
Copy link
Contributor Author

wilcol commented Dec 30, 2019

@Xerkus all done!

Copy link
Member

@Xerkus Xerkus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a bit of extra changes.

@@ -337,7 +337,7 @@ public function getFieldValue()
}

$sameSite = $this->getSameSite();
if ($sameSite !== null && in_array($sameSite, self::SAME_SITE_ALLOWED_VALUES, true)) {
if ($sameSite !== null && array_key_exists(strtolower($sameSite), self::SAME_SITE_ALLOWED_VALUES)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coding style: used functions must be imported with use function statements (under use block, separated by blank line)
Import just those you touched, that will be enough.

9,
SetCookie::SAME_SITE_STRICT
);
$this->assertEquals(SetCookie::SAME_SITE_STRICT, $setCookieHeader->getSameSite());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also test setSameSite() explicitly. Just once would be enough.

@wilcol wilcol requested a review from Xerkus December 30, 2019 10:41
Copy link
Member

@Xerkus Xerkus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks!

weierophinney added a commit that referenced this pull request Dec 30, 2019
@weierophinney
Copy link
Member

As this was a bugfix, I rebased against master and merged there for a new 2.11.2 release.

Thanks, @wilcol !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants