Skip to content

Commit

Permalink
RestEasy Reactive sends SameSite cookie param with wrong case
Browse files Browse the repository at this point in the history
Closes #38465

(cherry picked from commit a280efc)
  • Loading branch information
stianst authored and gsmet committed Jan 30, 2024
1 parent 78d9686 commit b4be787
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,21 @@ public String toString(Object value) {
b.append(";HttpOnly");
if (cookie.getSameSite() != null) {
b.append(";SameSite=");
b.append(cookie.getSameSite());
appendCorrectCase(b, cookie.getSameSite());
}
return b.toString();
}

private static void appendCorrectCase(final StringBuilder sb, final Enum<?> e) {
boolean first = true;
for (char c : e.name().toCharArray()) {
if (first) {
sb.append(c);
first = false;
} else {
sb.append(Character.toLowerCase(c));
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void testSameSite() {
.formParam("cookie", "greeting=\"hello\";SameSite=\"Lax\";")
.post("/cookies/set-cookie")
.then()
.cookie("greeting", detailedCookie().value("hello").sameSite("LAX"));
.cookie("greeting", detailedCookie().value("hello").sameSite("Lax"));
}

@Test
Expand All @@ -119,7 +119,7 @@ void testSameSiteWithoutColon() {
.formParam("cookie", "greeting=\"hello\";SameSite=\"None\"")
.post("/cookies/set-cookie")
.then()
.cookie("greeting", detailedCookie().value("hello").sameSite("NONE"));
.cookie("greeting", detailedCookie().value("hello").sameSite("None"));
}

@Test
Expand All @@ -130,7 +130,7 @@ void testSameSiteLowercase() {
.formParam("cookie", "greeting=\"hello\";samesite=\"Strict\"")
.post("/cookies/set-cookie")
.then()
.cookie("greeting", detailedCookie().value("hello").sameSite("STRICT"));
.cookie("greeting", detailedCookie().value("hello").sameSite("Strict"));
}

@Test
Expand Down

0 comments on commit b4be787

Please sign in to comment.