diff --git a/src/lib/app/profilemanager.cpp b/src/lib/app/profilemanager.cpp index 869633fd4..bcf81e680 100644 --- a/src/lib/app/profilemanager.cpp +++ b/src/lib/app/profilemanager.cpp @@ -413,7 +413,9 @@ void ProfileManager::updateDatabase() for (auto [feature, settingName] : html5SettingPairs.asKeyValueRange()) { auto const serverList = settings.value(settingName + suflix, QStringList()).toStringList(); - for (const auto &server : serverList) { + for (const auto &serverUrl : serverList) { + const auto server = SiteSettingsManager::adjustUrl(QUrl(serverUrl)); + if (!siteSettings.contains(server)) { siteSettings[server] = SiteSettingsManager::SiteSettings(); for (auto [f, nameUnused] : html5SettingPairs.asKeyValueRange()) { @@ -438,7 +440,8 @@ void ProfileManager::updateDatabase() auto loadCookiesSettings = [&](const QString &listName, const SiteSettingsManager::Permission permission) { auto const serverList = settings.value(listName, QStringList()).toStringList(); - for (const auto &server : serverList) { + for (const auto &serverUrl : serverList) { + const auto server = SiteSettingsManager::adjustUrl(QUrl(serverUrl)); if (!siteSettings.contains(server)) { siteSettings[server] = SiteSettingsManager::SiteSettings(); } diff --git a/src/lib/other/siteinfo.cpp b/src/lib/other/siteinfo.cpp index f0572ca68..8fbc85360 100644 --- a/src/lib/other/siteinfo.cpp +++ b/src/lib/other/siteinfo.cpp @@ -377,7 +377,7 @@ void SiteInfo::saveSiteSettings() siteSettings.AllowCookies = item->permission(); siteSettings.ZoomLevel = -1; - siteSettings.server = m_baseUrl.host(); + siteSettings.server = mApp->siteSettingsManager()->adjustUrl(m_baseUrl); auto storedSiteSettings = mApp->siteSettingsManager()->getSiteSettings(m_baseUrl); diff --git a/src/lib/other/sitesettingsmanager.cpp b/src/lib/other/sitesettingsmanager.cpp index fea44cde4..e324c84ef 100644 --- a/src/lib/other/sitesettingsmanager.cpp +++ b/src/lib/other/sitesettingsmanager.cpp @@ -95,7 +95,7 @@ void SiteSettingsManager::saveSettings() QHash SiteSettingsManager::getWebAttributes(const QUrl& url) { QHash attributes; - QString host = url.host(); + QString host = adjustUrl(url); if (host.isEmpty()) { for (int i = 0; i < supportedAttribute.size(); ++i) { @@ -133,7 +133,7 @@ QHash SiteSettingsManager::getWebAttribu void SiteSettingsManager::setOption(const QString& column, const QUrl& url, const int value) { - QString host = url.host(); + QString host = adjustUrl(url); if (column.isEmpty() || host.isEmpty()) { return; @@ -208,22 +208,22 @@ SiteSettingsManager::Permission SiteSettingsManager::getPermission(const QWebEng SiteSettingsManager::Permission SiteSettingsManager::getPermission(const QString &column, const QUrl& url) { - return getPermission(column, url.host()); + return getPermission(column, adjustUrl(url)); } SiteSettingsManager::Permission SiteSettingsManager::getPermission(const SiteSettingsManager::PageOptions option, const QUrl& url) { - return getPermission(optionToSqlColumn(option), url.host()); + return getPermission(optionToSqlColumn(option), adjustUrl(url)); } SiteSettingsManager::Permission SiteSettingsManager::getPermission(const QWebEnginePage::Feature feature, const QUrl& url) { - return getPermission(featureToSqlColumn(feature), url.host()); + return getPermission(featureToSqlColumn(feature), adjustUrl(url)); } SiteSettingsManager::Permission SiteSettingsManager::getPermission(const QWebEngineSettings::WebAttribute attribute, const QUrl& url) { - return getPermission(webAttributeToSqlColumn(attribute), url.host()); + return getPermission(webAttributeToSqlColumn(attribute), adjustUrl(url)); } SiteSettingsManager::Permission SiteSettingsManager::getDefaultPermission(const SiteSettingsManager::PageOptions option) @@ -464,9 +464,9 @@ QList SiteSettingsManager::getSupportedFeatures() const SiteSettingsManager::SiteSettings SiteSettingsManager::getSiteSettings(QUrl& url) { SiteSettings siteSettings; - siteSettings.server = url.host(); + siteSettings.server = adjustUrl(url); - if (url.isEmpty()) { + if (url.isEmpty() || siteSettings.server.isEmpty()) { return siteSettings; } @@ -474,7 +474,7 @@ SiteSettingsManager::SiteSettings SiteSettingsManager::getSiteSettings(QUrl& url QSqlQuery query(SqlDatabase::instance()->database()); query.prepare(everythingSql.arg(sqlTable())); - query.addBindValue(url.host()); + query.addBindValue(siteSettings.server); query.exec(); if (query.next()) { @@ -623,4 +623,17 @@ void SiteSettingsManager::prepareSqls() { everythingUpdateSql.append(QSL("=? ")); everythingUpdateSql.append(QSL(" WHERE server=?")); -} \ No newline at end of file +} + +QString SiteSettingsManager::adjustUrl(const QUrl url) +{ + QUrl urlAdjusted = url.adjusted( + QUrl::RemoveUserInfo + | QUrl::RemovePath + | QUrl::RemoveQuery + | QUrl::RemoveFragment + | QUrl::StripTrailingSlash + ); + + return urlAdjusted.toString(); +} diff --git a/src/lib/other/sitesettingsmanager.h b/src/lib/other/sitesettingsmanager.h index 35d02a3ae..6a6ebd1af 100644 --- a/src/lib/other/sitesettingsmanager.h +++ b/src/lib/other/sitesettingsmanager.h @@ -119,6 +119,8 @@ public: QString sqlTable(); Permission intToPermission(const int permission) const; + static QString adjustUrl(const QUrl url); + private: void prepareSqls();