Page 1 of 1

[RESOLVED] Not passing cookies for TLD-less link hrefs.

Posted: Wed Mar 27, 2013 10:52 am
by jumpy21230
Hello FlashGot Team,
I've been using your extension for several years now.
I found a bug which affects my usage while developing a download service on localhost that gives a download link that requires a cookie to work. FlashGot never passes the cookie correctly to the download manager. Specifically, it seems to have trouble associating the cookie with the link.

In the initCookies function in DMS.js, there is an attempt with regex to parse out the HTTP hostname from the link HREF. This regex is wrong and doesn't take into account that the hostname can have a port number or can be without a TLD (like localhost).

It appears Firefox doesn't store cookies with port numbers (even when the Set-Cookie header has the cookie domain parameter with port number), so when constructing the hostCookies dictionary, the port number must be ignored as well so it is passed properly to the download manager.

See patch below:

DMS.js (as of stable version 1.5.5), in initCookies function line: 379

Code: Select all

parts = l.href.match(/http[s]{0,1}:\/\/([^\/]+\.[^\/]+)/i); // host?
Change that line to:

Code: Select all

parts = l.href.match(/https?:\/\/([^\/:]+)(:\d+)?\//i); // host?
This completely solves the issue for me and doesn't seem to break anything.
In retrospect, there maybe an official sanctioned JS service in the framework to properly parse out URL components to prevent such bugs in the future, maybe that would be a better long term fix.

PS: Isn't there a bug tracker we can post bugs on ? Moving to bitbucket or github may help people contribute more to this project.
Cheers !

Re: [PATCH][BUG] Not passing cookies for TLD-less link hrefs

Posted: Sun May 19, 2013 4:51 pm
by jumpy21230
bump ? the issue is still there even in the latest version. Could we at least incorporate this patch into the next version ? or at least someone look at it ?
Thanks a lot in advance.

Re: [PATCH][BUG] Not passing cookies for TLD-less link hrefs

Posted: Sun May 19, 2013 9:09 pm
by Giorgio Maone
jumpy21230 wrote:bump ? the issue is still there even in the latest version. Could we at least incorporate this patch into the next version ? or at least someone look at it ?
Thanks a lot in advance.
Sorry, I completely missed the original post.
I'm gonna incorporate this regex or a variant in next release, thank you!

Re: [PATCH][BUG] Not passing cookies for TLD-less link hrefs

Posted: Sun May 19, 2013 10:40 pm
by Thrawn
jumpy21230 wrote: PS: Isn't there a bug tracker we can post bugs on ? Moving to bitbucket or github may help people contribute more to this project.
:D You're looking at the bug tracker! FlashGot is a one-man project (it belongs to Giorgio). The rest of the support team are not devs (not of FlashGot, at least), we just moderate.

Re: [PATCH][BUG] Not passing cookies for TLD-less link hrefs

Posted: Tue May 28, 2013 8:53 pm
by Giorgio Maone
Please check latest development build 1.5.5.5rc1, thank you.

Re: [PATCH][BUG] Not passing cookies for TLD-less link hrefs

Posted: Wed May 29, 2013 7:33 pm
by jumpy21230
The issue is now fixed for me, the cookie is passed correctly and the download works with no issues. Thank you !