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

Corrected issue where blank urls resulted in spurious returns to KeepassHTTP #1031

Merged
merged 1 commit into from
Oct 3, 2017

Conversation

droidmonkey
Copy link
Member

Description

Fixes #1017

How has this been tested?

Manually with debugger

Types of changes

  • ✅ Bug fix (non-breaking change which fixes an issue)

Checklist:

  • ✅ I have read the CONTRIBUTING document. [REQUIRED]
  • ✅ My code follows the code style of this project. [REQUIRED]
  • ✅ All new and existing tests passed. [REQUIRED]
  • ✅ I have compiled and verified my code with -DWITH_ASAN=ON. [REQUIRED]

@yan12125
Copy link
Contributor

yan12125 commented Oct 3, 2017

How about adding a test case? For example:

diff --git a/tests/TestEntry.cpp b/tests/TestEntry.cpp
index 4d34cf31..fe37ca22 100644
--- a/tests/TestEntry.cpp
+++ b/tests/TestEntry.cpp
@@ -19,6 +19,7 @@
 
 #include <QTest>
 
+#include "config-keepassx-tests.h"
 #include "core/Entry.h"
 #include "crypto/Crypto.h"
 
@@ -130,3 +131,12 @@ void TestEntry::testClone()
 
     delete entryOrg;
 }
+
+void TestEntry::testResolveUrl()
+{
+#ifdef WITH_XC_HTTP
+    Entry* entry = new Entry();
+    QCOMPARE(entry->resolveUrl(""), QString(""));
+    delete entry;
+#endif
+}
diff --git a/tests/TestEntry.h b/tests/TestEntry.h
index 0c97c0b9..3f6d20ee 100644
--- a/tests/TestEntry.h
+++ b/tests/TestEntry.h
@@ -31,6 +31,7 @@ private slots:
     void testHistoryItemDeletion();
     void testCopyDataFrom();
     void testClone();
+    void testResolveUrl();
 };
 
 #endif // KEEPASSX_TESTENTRY_H

testResolveUrl() should have more tests. This is just a proof-of-concept.

@droidmonkey
Copy link
Member Author

droidmonkey commented Oct 3, 2017

After reading the function a couple of times I don't like how the non-HTTP case returns an empty string. Shouldn't we just pass-through the input string? Seems like the behavior of this function is very complex and sometimes undefined.

@droidmonkey droidmonkey force-pushed the hotfix/keepasshttp-url branch from e7bb6c3 to 02ddb2b Compare October 3, 2017 18:58
@droidmonkey
Copy link
Member Author

OK, so after doing a little test-driven-development I found that the resolveUrl function was completely broken in a variety of cases. I corrected those and wrote many test cases for it to be run against. I also found that the WITH_XC_HTTP guards were completely unnecessary as QUrl is usable regardless of the HTTP presence.

@droidmonkey droidmonkey force-pushed the hotfix/keepasshttp-url branch from 02ddb2b to aae7b5a Compare October 3, 2017 19:02

void TestEntry::testResolveUrl()
{
Entry* entry = new Entry();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be deleted? Or maybe make resolveUrl a static function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't matter in a test. Technically it should be but it really doesn't matter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok made the change 😝

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QUrl may be usable, but WITH_XC_HTTP is also for those people who don't like networking functionality inside their password manager's code.

Copy link
Member Author

@droidmonkey droidmonkey Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no networking code in here. QUrl is just a container.

Copy link
Member

@phoerious phoerious Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I thought QUrl would also do some resolver work. But I guess I've just been doing to much Java as of late. :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was thinking the same thing when I first write that piece of code :D

Copy link
Contributor

@TheZ3ro TheZ3ro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for tests

@droidmonkey droidmonkey force-pushed the hotfix/keepasshttp-url branch from aae7b5a to 65829b6 Compare October 3, 2017 19:42
@droidmonkey droidmonkey merged commit 5098866 into release/2.2.2 Oct 3, 2017
@droidmonkey droidmonkey deleted the hotfix/keepasshttp-url branch October 3, 2017 22:40
phoerious added a commit that referenced this pull request Oct 21, 2017
- Fixed entries with empty URLs being reported to KeePassHTTP clients [#1031]
- Fixed YubiKey detection and enabled CLI tool for AppImage binary [#1100]
- Added AppStream description [#1082]
- Improved TOTP compatibility and added new Base32 implementation [#1069]
- Fixed error handling when processing invalid cipher stream [#1099]
- Fixed double warning display when opening a database [#1037]
- Fixed unlocking databases with --pw-stdin [#1087]
- Added ability to override QT_PLUGIN_PATH environment variable for AppImages [#1079]
- Fixed transform seed not being regenerated when saving the database [#1068]
- Fixed only one YubiKey slot being polled [#1048]
- Corrected an issue with entry icons while merging [#1008]
- Corrected desktop and tray icons in Snap package [#1030]
- Fixed screen lock and Google fallback settings [#1029]
@phoerious phoerious added pr: bugfix Pull request that fixes a bug and removed bug labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants