Skip to content

Commit

Permalink
Replace Google with DuckDuckGo for optional fallback favicon fetch URL
Browse files Browse the repository at this point in the history
Modify the work initially done in keepassxreboot#36, and most recently modified in keepassxreboot#1786,
to use DuckDuckGo's https://icons.duckduckgo.com/ip3/www.example.com.ico
favicon endpoint.

Fixes keepassxreboot#2258
  • Loading branch information
kneitinger committed Sep 20, 2018
1 parent f1a13a1 commit 265d530
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 199 deletions.
4 changes: 0 additions & 4 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,3 @@ License: LGPL-2.1
Files: share/macosx/dmg-background.tiff
Copyright: 2008-2014, Andrey Tarantsov
License: MIT

Files: cmake/DeployQt.cmake
Copyright: 2018, Nathan Osman
License: MIT
31 changes: 0 additions & 31 deletions appveyor.yml

This file was deleted.

21 changes: 0 additions & 21 deletions ci/appveyor/before-build.sh

This file was deleted.

5 changes: 0 additions & 5 deletions ci/appveyor/build.sh

This file was deleted.

24 changes: 0 additions & 24 deletions ci/appveyor/install.sh

This file was deleted.

6 changes: 0 additions & 6 deletions ci/appveyor/test.sh

This file was deleted.

88 changes: 0 additions & 88 deletions cmake/DeployQt.cmake

This file was deleted.

11 changes: 7 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,11 @@ if(APPLE AND WITH_APP_BUNDLE)
set(CPACK_PACKAGE_FILE_NAME "${PROGNAME}-${KEEPASSXC_VERSION}")
include(CPack)

include(DeployQt)
macdeployqt(${PROGNAME})
add_custom_command(TARGET ${PROGNAME}
POST_BUILD
COMMAND ${MACDEPLOYQT_EXE} ${PROGNAME}.app
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src
COMMENT "Deploying app bundle")
endif()

install(TARGETS ${PROGNAME}
Expand Down Expand Up @@ -390,8 +393,8 @@ if(MINGW)
set(gp_tool \"objdump\")
" COMPONENT Runtime)

include(DeployQt)
windeployqt(${PROGNAME})
include(DeployQt4)
install_qt4_executable(${PROGNAME}.exe)

# install Qt5 plugins
set(PLUGINS_DIR ${Qt5_PREFIX}/share/qt5/plugins)
Expand Down
3 changes: 1 addition & 2 deletions src/autotype/mac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ set_target_properties(keepassx-autotype-cocoa PROPERTIES LINK_FLAGS "-framework
target_link_libraries(keepassx-autotype-cocoa ${PROGNAME} Qt5::Core Qt5::Widgets)

if(WITH_APP_BUNDLE)
include(DeployQt)
add_custom_command(TARGET keepassx-autotype-cocoa
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/libkeepassx-autotype-cocoa.so ${PLUGIN_INSTALL_DIR}
COMMAND ${MACDEPLOYQT_EXECUTABLE} ${PROGNAME}.app -executable=${PLUGIN_INSTALL_DIR}/libkeepassx-autotype-cocoa.so -no-plugins
COMMAND ${MACDEPLOYQT_EXE} ${PROGNAME}.app -executable=${PLUGIN_INSTALL_DIR}/libkeepassx-autotype-cocoa.so -no-plugins
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src
COMMENT "Deploying autotype plugin")
else()
Expand Down
2 changes: 1 addition & 1 deletion src/core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void Config::init(const QString& fileName)
m_defaults.insert("security/passwordscleartext", false);
m_defaults.insert("security/hidepassworddetails", true);
m_defaults.insert("security/autotypeask", true);
m_defaults.insert("security/IconDownloadFallbackToGoogle", false);
m_defaults.insert("security/IconDownloadFallbackToDuckDuckGo", false);
m_defaults.insert("security/resettouchid", false);
m_defaults.insert("security/resettouchidtimeout", 30);
m_defaults.insert("security/resettouchidscreenlock", true);
Expand Down
23 changes: 14 additions & 9 deletions src/gui/EditWidgetIcons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ UrlFetchProgressDialog::UrlFetchProgressDialog(const QUrl &url, QWidget *parent)
setWindowTitle(tr("Download Progress"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setLabelText(tr("Downloading %1.").arg(url.toDisplayString()));
setMinimumDuration(2000);
setMinimumDuration(0);
setMinimumSize(QSize(400, 75));
}

Expand Down Expand Up @@ -219,12 +219,12 @@ void EditWidgetIcons::downloadFavicon()
}
m_urlsToTry.append(QUrl(m_url.scheme() + "://" + secondLevelDomain + "/favicon.ico"));

// Try to use Google fallback, if enabled
if (config()->get("security/IconDownloadFallbackToGoogle", false).toBool()) {
QUrl urlGoogle = QUrl("https://www.google.com/s2/favicons");
// Try to use DuckDuckGo fallback, if enabled
if (config()->get("security/IconDownloadFallbackToDuckDuckGo", false).toBool()) {
QUrl urlDuckDuckGo = QUrl("https://icons.duckduckgo.com");

urlGoogle.setQuery("domain=" + QUrl::toPercentEncoding(secondLevelDomain));
m_urlsToTry.append(urlGoogle);
urlDuckDuckGo.setPath("/ip3/" + QUrl::toPercentEncoding(fullyQualifiedDomain) + ".ico");
m_urlsToTry.append(urlDuckDuckGo);
}

startFetchFavicon(m_urlsToTry.takeFirst());
Expand All @@ -242,8 +242,9 @@ void EditWidgetIcons::fetchFinished()
{
#ifdef WITH_XC_NETWORKING
QImage image;
bool googleFallbackEnabled = config()->get("security/IconDownloadFallbackToGoogle", false).toBool();
bool duckDuckGoFallbackEnabled = config()->get("security/IconDownloadFallbackToDuckDuckGo", false).toBool();
bool error = (m_reply->error() != QNetworkReply::NoError);
QUrl url = m_reply->url();
QUrl redirectTarget = getRedirectTarget(m_reply);

m_reply->deleteLater();
Expand All @@ -264,6 +265,9 @@ void EditWidgetIcons::fetchFinished()
// No redirect, and we theoretically have some icon data now.
image.loadFromData(m_bytesReceived);
}
} else {
UrlFetchProgressDialog *progress = findChild<UrlFetchProgressDialog *>(url.toString());
progress->close();
}

if (!image.isNull()) {
Expand All @@ -275,9 +279,9 @@ void EditWidgetIcons::fetchFinished()
startFetchFavicon(m_urlsToTry.takeFirst());
return;
} else {
if (!googleFallbackEnabled) {
if (!duckDuckGoFallbackEnabled) {
emit messageEditEntry(tr("Unable to fetch favicon.") + "\n" +
tr("Hint: You can enable Google as a fallback under Tools>Settings>Security"),
tr("Hint: You can enable DuckDuckGo as a fallback under Tools>Settings>Security"),
MessageWidget::Error);
} else {
emit messageEditEntry(tr("Unable to fetch favicon."), MessageWidget::Error);
Expand Down Expand Up @@ -311,6 +315,7 @@ void EditWidgetIcons::startFetchFavicon(const QUrl& url)
connect(m_reply, &QIODevice::readyRead, this, &EditWidgetIcons::fetchReadyRead);

UrlFetchProgressDialog *progress = new UrlFetchProgressDialog(url, this);
progress->setObjectName(url.toString());
progress->setAttribute(Qt::WA_DeleteOnClose);
connect(m_reply, &QNetworkReply::finished, progress, &QProgressDialog::hide);
connect(m_reply, &QNetworkReply::downloadProgress, progress, &UrlFetchProgressDialog::networkReplyProgress);
Expand Down
4 changes: 2 additions & 2 deletions src/gui/SettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void SettingsWidget::loadSettings()
m_secUi->lockDatabaseMinimizeCheckBox->setChecked(config()->get("security/lockdatabaseminimize").toBool());
m_secUi->lockDatabaseOnScreenLockCheckBox->setChecked(config()->get("security/lockdatabasescreenlock").toBool());
m_secUi->relockDatabaseAutoTypeCheckBox->setChecked(config()->get("security/relockautotype").toBool());
m_secUi->fallbackToGoogle->setChecked(config()->get("security/IconDownloadFallbackToGoogle").toBool());
m_secUi->fallbackToDuckDuckGo->setChecked(config()->get("security/IconDownloadFallbackToDuckDuckGo").toBool());

m_secUi->passwordCleartextCheckBox->setChecked(config()->get("security/passwordscleartext").toBool());
m_secUi->passwordDetailsCleartextCheckBox->setChecked(config()->get("security/hidepassworddetails").toBool());
Expand Down Expand Up @@ -256,7 +256,7 @@ void SettingsWidget::saveSettings()
config()->set("security/lockdatabaseminimize", m_secUi->lockDatabaseMinimizeCheckBox->isChecked());
config()->set("security/lockdatabasescreenlock", m_secUi->lockDatabaseOnScreenLockCheckBox->isChecked());
config()->set("security/relockautotype", m_secUi->relockDatabaseAutoTypeCheckBox->isChecked());
config()->set("security/IconDownloadFallbackToGoogle", m_secUi->fallbackToGoogle->isChecked());
config()->set("security/IconDownloadFallbackToDuckDuckGo", m_secUi->fallbackToDuckDuckGo->isChecked());

config()->set("security/passwordscleartext", m_secUi->passwordCleartextCheckBox->isChecked());
config()->set("security/hidepassworddetails", m_secUi->passwordDetailsCleartextCheckBox->isChecked());
Expand Down
4 changes: 2 additions & 2 deletions src/gui/SettingsWidgetSecurity.ui
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="fallbackToGoogle">
<widget class="QCheckBox" name="fallbackToDuckDuckGo">
<property name="text">
<string>Use Google as fallback for downloading website icons</string>
<string>Use DuckDuckGo as fallback for downloading website icons</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 265d530

Please sign in to comment.