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

Create new UrlTools class #9935

Merged

Conversation

varjolintu
Copy link
Member

Creates a new UrlTools class.
Every URL related check function from BrowserService and IconDownloader classes are moved to the new class. Some of the functions are only used if WITH_XC_NETWORKING is enabled.

Also solves the problem with deprecated QUrl::topLevelDomain() and replaces it with a proper TLD check using Qt's Public Suffix List from QNetworkCookie and QNetworkCookieJar classes.

Related to #7783.

Testing strategy

Automatic tests added.

Type of change

  • ✅ Refactor (significant modification to existing code)

@varjolintu varjolintu added this to the v2.8.0 milestone Oct 15, 2023
@droidmonkey droidmonkey merged commit 8f45431 into keepassxreboot:develop Oct 24, 2023
11 checks passed
@varjolintu varjolintu deleted the feature/create_urltools_class branch October 24, 2023 03:49
@molgen-edv
Copy link

Definition of some methods is #ifdef WITH_XC_NETWORKING but usage is not.

/home/buczek/git/keepassxc/src/browser/BrowserService.cpp: In member function ‘bool BrowserService::handleURL(const QString&, const QString&, const QString&, bool)’:
/home/buczek/git/keepassxc/src/browser/BrowserService.cpp:1427:21: error: ‘class UrlTools’ has no member named ‘getBaseDomainFromUrl’
 1427 |     if (urlTools()->getBaseDomainFromUrl(siteQUrl.host()) != urlTools()->getBaseDomainFromUrl(entryQUrl.host())) {
      |                     ^~~~~~~~~~~~~~~~~~~~
/home/buczek/git/keepassxc/src/browser/BrowserService.cpp:1427:74: error: ‘class UrlTools’ has no member named ‘getBaseDomainFromUrl’
 1427 |     if (urlTools()->getBaseDomainFromUrl(siteQUrl.host()) != urlTools()->getBaseDomainFromUrl(entryQUrl.host())) {
      |                                                                          ^~~~~~~~~~~~~~~~~~~~
make[2]: *** [src/browser/CMakeFiles/keepassxcbrowser.dir/build.make:202: src/browser/CMakeFiles/keepassxcbrowser.dir/BrowserService.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:750: src/browser/CMakeFiles/keepassxcbrowser.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

@varjolintu
Copy link
Member Author

@molgen-edv WITH_XC_BROWSER needs WITH_XC_NETWORKING.

@buczek
Copy link

buczek commented Dec 11, 2023

[ Answering with my personal account, used @molgen-edv by accident ]

Thanks. Note: Our current deployment script uses WITH_XC_BROWSER but not WITH_XC_NETWORKING and with previous versions (2.7.6), the software compiles and browser integration does work. If this is a new requirement, maybe CMakeList.txt and/or INSTALL.md should be updated, which currently say WITH_XC_NETWORKING is needed for things like "favicon downloading" and the dependency of WITH_XC_BROWSER is not expressed.

@droidmonkey
Copy link
Member

The error is in UrlTools.cpp, we should include this code if browser OR networking is enabled. Browser does not require networking. We have a test when all features are disabled, but not a test for the combo of network disabled and browser enabled, which is why this was missed.

@varjolintu
Copy link
Member Author

Fixed in #10094.

@buczek
Copy link

buczek commented Dec 11, 2023

Great, thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants