Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(std/http): Add Cookie value validation #8471

Merged
merged 9 commits into from
Dec 1, 2020
Prev Previous commit
Next Next commit
test(std/http): Testing cookie value validation
  • Loading branch information
getspooky committed Nov 23, 2020
commit 7cdd28a138524336e0d2d84289dc43b4f3d5d82a
38 changes: 38 additions & 0 deletions std/http/cookie_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,44 @@ Deno.test({
},
});

Deno.test({
name: "Cookie Value Validation",
fn(): void {
const res: Response = {};
const tokens = [
"1f\tWa",
"\t",
"1f Wa",
"1f;Wa",
'"1fWa',
"1f\\Wa",
'1f"Wa',
'"',
"1fWa\u0005",
"1f\u0091Wa",
];
res.headers = new Headers();
tokens.forEach((value) => {
assertThrows(
(): void => {
setCookie(
res,
{
name: "Space",
value,
httpOnly: true,
secure: true,
maxAge: 3
},
);
},
Error,
"RFC2616 cookie value",
);
});
},
});

Deno.test({
name: "Cookie Path Validation",
fn(): void {
Expand Down