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

Bug reports and enhancement requests
Post Reply
jumpy21230
Posts: 3
Joined: Wed Mar 27, 2013 10:22 am

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

Post 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 !
Mozilla/5.0 (Windows NT 6.2; rv:19.0) Gecko/20100101 Firefox/19.0
jumpy21230
Posts: 3
Joined: Wed Mar 27, 2013 10:22 am

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

Post 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.
Mozilla/5.0 (Windows NT 6.2; rv:21.0) Gecko/20100101 Firefox/21.0
User avatar
Giorgio Maone
Site Admin
Posts: 9454
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

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

Post 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!
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0
User avatar
Thrawn
Master Bug Buster
Posts: 3106
Joined: Mon Jan 16, 2012 3:46 am
Location: Australia
Contact:

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

Post 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.
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0
User avatar
Giorgio Maone
Site Admin
Posts: 9454
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

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

Post by Giorgio Maone »

Please check latest development build 1.5.5.5rc1, thank you.
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0
jumpy21230
Posts: 3
Joined: Wed Mar 27, 2013 10:22 am

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

Post by jumpy21230 »

The issue is now fixed for me, the cookie is passed correctly and the download works with no issues. Thank you !
Mozilla/5.0 (Windows NT 6.2; rv:21.0) Gecko/20100101 Firefox/21.0
Post Reply