fix: do not return cookies with empty values (#5147)
This commit is contained in:
parent
2e290be40b
commit
87a3ccc49e
|
|
@ -23,6 +23,9 @@ export function filterCookies(cookies: types.NetworkCookie[], urls: string[]): t
|
||||||
const parsedURLs = urls.map(s => new URL(s));
|
const parsedURLs = urls.map(s => new URL(s));
|
||||||
// Chromiums's cookies are missing sameSite when it is 'None'
|
// Chromiums's cookies are missing sameSite when it is 'None'
|
||||||
return cookies.filter(c => {
|
return cookies.filter(c => {
|
||||||
|
// Firefox and WebKit can return cookies with empty values.
|
||||||
|
if (!c.value)
|
||||||
|
return false;
|
||||||
if (!parsedURLs.length)
|
if (!parsedURLs.length)
|
||||||
return true;
|
return true;
|
||||||
for (const parsedURL of parsedURLs) {
|
for (const parsedURL of parsedURLs) {
|
||||||
|
|
|
||||||
|
|
@ -199,3 +199,14 @@ it('should work with subdomain cookie', async ({context, page, server}) => {
|
||||||
sameSite: 'None',
|
sameSite: 'None',
|
||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not return cookies with empty value', async ({context, page, server}) => {
|
||||||
|
server.setRoute('/empty.html', (req, res) => {
|
||||||
|
res.setHeader('Set-Cookie', 'name=;Path=/');
|
||||||
|
res.end();
|
||||||
|
});
|
||||||
|
await page.goto(server.EMPTY_PAGE);
|
||||||
|
const cookies = await context.cookies();
|
||||||
|
expect(cookies.length).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue