Fix two problems with URL wildcard matching

* Fixes #12255
* Periods were not being escaped in the url string before being used in a regex resulting in matching 'any character' between domain parts
* Wildcards entered as `*.` were being replaced with simply `*` resulting in unexpected matches to occur. Fixing this has a side effect of `https://*.github.com` NOT matching `https://github.com` which should be the expected behavior. Users can enter both url's if they desire to match the primary and all sub domains or leave out the wildcard entirely to use normal matching behavior.
This commit is contained in:
Jonathan White
2025-07-02 18:29:57 -04:00
parent 634a5b34f1
commit 74326616c5
2 changed files with 5 additions and 6 deletions

View File

@@ -411,6 +411,7 @@ void TestBrowser::testSearchEntriesWithWildcardURLs()
"https://subdomain.*.github.com/*/second",
"https://*.sub.github.com/*",
"https://********", // Invalid wildcard URL
"https://*.thub.com/", // Partial suffix URL
"https://subdomain.yes.github.com/*",
"https://example.com:8448/*",
"https://example.com/*/*",
@@ -433,13 +434,12 @@ void TestBrowser::testSearchEntriesWithWildcardURLs()
auto result = m_browserService->searchEntries(
db, "https://github.com/login_page/second", "https://github.com/login_page/second");
QCOMPARE(result.length(), 6);
QCOMPARE(result.length(), 5);
QCOMPARE(firstUrl(result[0]), QString("https://github.com/login_page/*"));
QCOMPARE(firstUrl(result[1]), QString("https://github.com/*/second"));
QCOMPARE(firstUrl(result[2]), QString("https://github.com/*"));
QCOMPARE(firstUrl(result[3]), QString("http://github.com/*"));
QCOMPARE(firstUrl(result[4]), QString("github.com/*"));
QCOMPARE(firstUrl(result[5]), QString("https://*.github.com/*"));
result = m_browserService->searchEntries(
db, "https://subdomain.sub.github.com/login_page/second", "https://subdomain.sub.github.com/login_page/second");
@@ -503,12 +503,11 @@ void TestBrowser::testSearchEntriesWithWildcardURLs()
result = m_browserService->searchEntries(
db, "https://github.com/login_page/second", "https://github.com/login_page/second");
QCOMPARE(result.length(), 5);
QCOMPARE(result.length(), 4);
QCOMPARE(firstUrl(result[0]), QString("https://github.com/login_page/*"));
QCOMPARE(firstUrl(result[1]), QString("https://github.com/*/second"));
QCOMPARE(firstUrl(result[2]), QString("https://github.com/*"));
QCOMPARE(firstUrl(result[3]), QString("github.com/*")); // Defaults to https
QCOMPARE(firstUrl(result[4]), QString("https://*.github.com/*"));
}
void TestBrowser::testInvalidEntries()