Skip to content

Commit

Permalink
Ignore invalid cookies supplied by YouTube (#765)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz authored Jan 18, 2024
1 parent bd5e6ae commit 3118f02
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion YoutubeExplode/YoutubeHttpHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,20 @@ private HttpResponseMessage HandleResponse(HttpResponseMessage response)
if (response.Headers.TryGetValues("Set-Cookie", out var cookieHeaderValues))
{
foreach (var cookieHeaderValue in cookieHeaderValues)
_cookieContainer.SetCookies(response.RequestMessage.RequestUri, cookieHeaderValue);
{
try
{
_cookieContainer.SetCookies(
response.RequestMessage.RequestUri,
cookieHeaderValue
);
}
catch (CookieException)
{
// YouTube may send cookies for other domains, ignore them
// https://github.com/Tyrrrz/YoutubeExplode/issues/762
}
}
}

return response;
Expand Down

0 comments on commit 3118f02

Please sign in to comment.