Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix favicon download from URL with non-standard port. #5509

Conversation

libklein
Copy link
Contributor

@libklein libklein commented Oct 4, 2020

Fixes #5001 and #2843.

The favicon download URL was constructed from scheme and host only. This is fixed by simply replacing the path of the original URL with "/favicon.ico", thus keeping scheme, host, auth and port intact.

Further modification: URL's with a non-http schema are now rejected. (See #2843)

Testing strategy

Tested URLs mentioned in #5001 and several well-known domains.

Type of change

  • ✅ Bug fix (non-breaking change that fixes an issue)
  • ✅ Breaking change (causes existing functionality to change)

@libklein
Copy link
Contributor Author

libklein commented Oct 4, 2020

As a side note: Perhaps a refactor of the IconDownloader is in order. Right now it tries to download the favicon not only from the host itself, but also from the second-level domain. I'd argue that it would make more sense to consider the host only, i.e. get rid of the second-level domain request.

Moreover, it would be nice to support the W3C recommendation regarding favicons, i.e. to (rudimentarily) parse the page and extract the various tags (c.f. wikipedia).

Any feelings towards this? I'd be happy to provide an implementation, just wanted to hear your opinion on the matter first.

@droidmonkey
Copy link
Member

We are not interested in parsing html... but maybe if we just did a very simple regex version.

@droidmonkey
Copy link
Member

Also when using the scheme functions calls of QUrl you do not add the ://

@libklein
Copy link
Contributor Author

libklein commented Oct 4, 2020

Also when using the scheme functions calls of QUrl you do not add the ://

Sorry about that. Will fix it tomorrow (or perhaps wait for #5504, if that is preferred) and then rebase on top of that.

We are not interested in parsing html... but maybe if we just did a very simple regex version.

I agree, that seems like a bit much given that most cases are covered by "/favicon.ico" anyway. What about getting rid of the second-level domain request?

@droidmonkey
Copy link
Member

If we regex the html we can get rid of the second level domains.

@droidmonkey droidmonkey added this to the v2.6.2 milestone Oct 6, 2020
@libklein libklein force-pushed the hotfix/5001-favicon-download-with-port-in-url branch from 07306fd to c6eda71 Compare October 11, 2020 19:10
@libklein
Copy link
Contributor Author

I've rebased onto #5504, fixed the schema bug and added a test case covering some corner cases, such as query strings, username/password in url and nested domains.

@droidmonkey droidmonkey modified the milestones: v2.6.2, v2.7.0 Oct 17, 2020
@libklein
Copy link
Contributor Author

Hi, i just wanted to ask whats the state on this? Are you planning to merge this (soon) or is there something wrong with the PR?

@droidmonkey
Copy link
Member

Its in the review queue, you don't have to do anything

@phoerious
Copy link
Member

Perhaps we can even split all the downloading functionality into a separate binary for address space separation as an additional mitigation against parser exploits. Then I'd even be fine with doing some more advanced logic than regex.

@libklein libklein force-pushed the hotfix/5001-favicon-download-with-port-in-url branch from a22d528 to 38d418c Compare December 21, 2020 20:54
@libklein libklein requested a review from phoerious December 22, 2020 18:00
@libklein
Copy link
Contributor Author

Hi,

sorry to bother you guys again, but are there any plans to merge this in the near future?

Best regards,
Patrick.

@droidmonkey
Copy link
Member

Yes sorry this has been on my review list. Getting through it!

src/gui/IconDownloader.cpp Outdated Show resolved Hide resolved
src/gui/IconDownloader.cpp Show resolved Hide resolved
Fixes keepassxreboot#5001.

The favicon download URL was constructed from scheme and host only. This is fixed by simply replacing the path of the original URL with "/favicon.ico", thus keeping scheme, host, auth and port intact.

Further modification: URL's with a non-http schema are now rejected.
@droidmonkey droidmonkey force-pushed the hotfix/5001-favicon-download-with-port-in-url branch from 897598d to 552532d Compare March 2, 2021 01:29
@droidmonkey droidmonkey merged commit 57af7c1 into keepassxreboot:develop Mar 2, 2021
@phoerious phoerious added pr: new feature Pull request that adds a new feature and removed new feature labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: new feature Pull request that adds a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Download favicon.ico not possible with port number in URL
3 participants