Bug 437515 - FavIconsCache doesn't work for non-default ports
Summary: FavIconsCache doesn't work for non-default ports
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: git master
Platform: Debian unstable Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-22 19:53 UTC by Daniel Roschka
Modified: 2021-05-27 15:40 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.83


Attachments
Proposed patch to fix this issue (813 bytes, patch)
2021-05-22 19:53 UTC, Daniel Roschka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Roschka 2021-05-22 19:53:49 UTC
Created attachment 138687 [details]
Proposed patch to fix this issue

SUMMARY

FavIconsCache is supposed to fetch and cache favicons. However when trying to download the favicon, only scheme and host of the original URL are taken into consideration, but the port isn't. That leads to failing favicon downloads if the original URL uses a non-default port.

An easy way to reproduce this behavior is by using Akregator.

STEPS TO REPRODUCE
1. Create two temporary directories (e.g. /tmp/dir1 and /tmp/dir2)
2. Download an arbitrary RSS or Atom feed (e.g. curl https://kde.org/index.xml > /tmp/dir1/index.xml)
3. Download an icon to use as favicon (e.g. curl https://kde.org/favicon.ico > /tmp/dir1/favicon.ico)
4. Start a local webserver in the directory you stored the feed in on a non-default port (e.g. python3 -mhttp.server --directory /tmp/dir1 8080)
5. Start a second local webserver on the default HTTP port (e.g. sudo python3 -mhttp.server --directory /tmp/dir2 80)
6. Open Akregator and add the feed hosted by your local webserver on the non-default port (http://localhost:8080/index.xml)

OBSERVED RESULT

No favicon is shown in Akregator and the access log of the webserver serving the feed doesn't show any request for the favicon. The webserver running on port 80 does however show a request for the favicon.

EXPECTED RESULT

A favicon is shown in Akregator.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
Akregator version: 5.15.3
KDE Plasma Version: 5.20.5
KDE Frameworks Version: 5.78.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION

A tracked the bug down to src/core/faviconscache.cpp where the port isn't properly set when generating iconUrl: https://invent.kde.org/frameworks/kio/-/blob/master/src/core/faviconscache.cpp#L132-137

A fix should be trivial and I attached a patch I suspect would fix it. As I'm not into C++ and have no dev setup for KDE I couldn't test it however.
Comment 1 Nate Graham 2021-05-26 17:13:05 UTC
Thanks for the patch! Unfortunately patches in bug reports tend to get lost. Can you please submit it at https://invent.kde.org/frameworks/kio/-/merge_requests/? Even if you can't test it, someone else probably can once it's up there.
Comment 2 Daniel Roschka 2021-05-27 03:54:02 UTC
Here you go: https://invent.kde.org/frameworks/kio/-/merge_requests/458
Comment 3 Nate Graham 2021-05-27 13:45:32 UTC
Thank you!
Comment 4 Nate Graham 2021-05-27 15:40:11 UTC
Fixed by Daniel Roschka with https://invent.kde.org/frameworks/kio/-/commit/90ff8140d37a26169034b0a2a1a9106b7482beba in Frameworks 5.83!