Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

Commit

Permalink
Allows to load the Tumblr ToS cookie separately.
Browse files Browse the repository at this point in the history
Previously, TumblThree agreed to the new Tumblr ToS (GDPR changes) at
each startup because there is an issue storing and loading cookies
without subdomain using the CookieContainer as well as the wininet.dll.
You need a URI to specify the cookies you want, but this fails is they
are prefixed with a dot for a whole domain cookie as it is the case for
the Tumblr ToS cookie.

That cookie interfered with the ToS cookie retrieved from logging into
Tumblr, hence invalidating the login.

The TumblrBlogDetector.cs now uses only the ToS cookie that is generated
at startup without login information to be able to differentiate between
blogs, hidden blogs, tumblr searches or tumblr liked-by downloads that
either require a login or can be access without being logged in. (#240)
  • Loading branch information
johanneszab committed Jun 9, 2018
1 parent e5719b2 commit 0ffdb56
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/TumblThree/SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

[assembly: ComVisible(false)]
[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.MainAssembly)]
[assembly: AssemblyVersion("1.0.8.50")]
[assembly: AssemblyFileVersion("1.0.8.50")]
[assembly: AssemblyVersion("1.0.8.51")]
[assembly: AssemblyFileVersion("1.0.8.51")]
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public async Task<bool> IsPasswordProtectedTumblrBlog(string url)
private async Task<string> GetUrlRedirection(string url)
{
HttpWebRequest request = webRequestFactory.CreateGetReqeust(url);
cookieService.GetUriCookie(request.CookieContainer, new Uri("https://www.tumblr.com/"));
cookieService.GetTumblrToSCookie(request.CookieContainer, new Uri("https://www.tumblr.com/"));
string location;
using (var response = await request.GetResponseAsync() as HttpWebResponse)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ private HttpWebRequest CreateStubReqeust(string url)
request.ReadWriteTimeout = settings.TimeOut * 1000;
request.Timeout = settings.TimeOut * 1000;
request.CookieContainer = new CookieContainer();
request.CookieContainer.PerDomainCapacity = 100;
ServicePointManager.DefaultConnectionLimit = 400;
request = SetWebRequestProxy(request, settings);
return request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public interface ISharedCookieService
{
void GetUriCookie(CookieContainer request, Uri uri);

void GetTumblrToSCookie(CookieContainer request, Uri uri);

void SetUriCookie(CookieCollection cookies);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,18 @@ static extern bool InternetSetCookie(

public void GetUriCookie(CookieContainer request, Uri uri)
{
foreach (Cookie cookie in cookieContainer.GetCookies(uri))
{
request.Add(cookie);
}
foreach (Cookie cookie in GetUriCookieContainer(uri).GetCookies(uri))
{
request.Add(cookie);
}
}

public void GetTumblrToSCookie(CookieContainer request, Uri uri)
{
foreach (Cookie cookie in cookieContainer.GetCookies(uri))
{
request.Add(cookie);
Expand Down

0 comments on commit 0ffdb56

Please sign in to comment.