fix(cookies): normalize SameSite value to title-case on parse (#270)
SameSite is case-insensitive per RFC 6265bis but servers send it in any casing (lax, LAX, Lax). Normalize to title-case at parse time so downstream comparisons work regardless. Unknown values fall back to Lax per spec.
This commit is contained in:
1 parent
6ba3c63596
commit
dd7395a80a
1 file changed
+16
-2
@@ -72,7 +72,14 @@ impl CookieJar {
|
||||
}
|
||||
}
|
||||
"samesite" => {
|
||||
same_site = val.trim().to_string();
|
||||
// SameSite is case-insensitive per RFC 6265bis; normalize to
|
||||
// title-case so downstream comparisons work regardless of what
|
||||
// the server sent. Unknown values default to Lax per spec.
|
||||
same_site = match val.trim().to_ascii_lowercase().as_str() {
|
||||
"strict" => "Strict",
|
||||
"none" => "None",
|
||||
_ => "Lax",
|
||||
}.to_string();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -280,7 +287,14 @@ impl CookieJar {
|
||||
}
|
||||
}
|
||||
"samesite" => {
|
||||
same_site = val.trim().to_string();
|
||||
// SameSite is case-insensitive per RFC 6265bis; normalize to
|
||||
// title-case so downstream comparisons work regardless of what
|
||||
// the server sent. Unknown values default to Lax per spec.
|
||||
same_site = match val.trim().to_ascii_lowercase().as_str() {
|
||||
"strict" => "Strict",
|
||||
"none" => "None",
|
||||
_ => "Lax",
|
||||
}.to_string();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user