Add support for URL wildcards and exact URL (#9835)

* Add support for URL wildcards with Additional URL feature

* Only check TLD if wildcard is used

* Avoid using network function in no-feature build

---------

Co-authored-by: varjolintu <sami.vanttinen@ahmala.org>
Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
Sami Vänttinen 2025-02-10 03:03:15 +02:00 committed by GitHub
parent 51e8c042af
commit 9ba6ada266
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 317 additions and 36 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2025 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -136,6 +136,36 @@ void TestUrlTools::testIsUrlValid()
}
}
void TestUrlTools::testIsUrlValidWithLooseComparison()
{
QHash<QString, bool> urls;
urls[""] = true;
urls["\"https://github.com/login\""] = true;
urls["https://*.github.com/"] = true;
urls["*.github.com"] = true;
urls["https://*.com"] = false;
urls["https://*.computer.com"] = true; // TLD in domain (com) should not affect
urls["\"\""] = false;
urls["\"*.example.com\""] = false;
urls["http://*"] = false;
urls["*"] = false;
urls["****"] = false;
urls["*.co.jp"] = false;
urls["*.com"] = false;
urls["*.computer.com"] = true;
urls["*.computer.com/*com"] = true; // TLD in path should not affect this
urls["*com"] = false;
urls["*.com/"] = false;
urls["*.com/*"] = false;
urls["**.com/**"] = false;
QHashIterator<QString, bool> i(urls);
while (i.hasNext()) {
i.next();
QCOMPARE(urlTools()->isUrlValid(i.key(), true), i.value());
}
}
void TestUrlTools::testDomainHasIllegalCharacters()
{
QVERIFY(!urlTools()->domainHasIllegalCharacters("example.com"));