Skip to content

Commit

Permalink
Correct identified issues
Browse files Browse the repository at this point in the history
  • Loading branch information
droidmonkey committed Oct 9, 2018
1 parent 7553c54 commit 3b993ef
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/core/EntrySearcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ QList<QSharedPointer<EntrySearcher::SearchTerm> > EntrySearcher::parseSearchTerm
auto results = m_termParser.globalMatch(searchString);
while (results.hasNext()) {
auto result = results.next();
QSharedPointer<SearchTerm> term(new SearchTerm());
auto term = QSharedPointer<SearchTerm>::create();

// Quoted string group
term->word = result.captured(3);
Expand Down
2 changes: 1 addition & 1 deletion src/core/EntrySearcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class EntrySearcher
private:
bool searchEntryImpl(const QString& searchString, Entry* entry);

enum Field {
enum class Field {
Undefined,
Title,
Username,
Expand Down
1 change: 0 additions & 1 deletion src/core/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ QRegularExpression convertToRegex(const QString& string, bool useWildcards, bool
// Wildcard support (*, ?, |)
if (useWildcards) {
pattern.replace(regexEscape, "\\\\1");
pattern.replace("**", "*");
pattern.replace("*", ".*");
pattern.replace("?", ".");
}
Expand Down
14 changes: 7 additions & 7 deletions tests/TestEntrySearcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,31 +144,31 @@ void TestEntrySearcher::testSearchTermParser()

QCOMPARE(terms.length(), 5);

QCOMPARE(terms[0]->field, EntrySearcher::Undefined);
QCOMPARE(terms[0]->field, EntrySearcher::Field::Undefined);
QCOMPARE(terms[0]->word, QString("test"));
QCOMPARE(terms[0]->exclude, true);

QCOMPARE(terms[1]->field, EntrySearcher::Undefined);
QCOMPARE(terms[1]->field, EntrySearcher::Field::Undefined);
QCOMPARE(terms[1]->word, QString("quoted \\\"string\\\""));
QCOMPARE(terms[1]->exclude, false);

QCOMPARE(terms[2]->field, EntrySearcher::Username);
QCOMPARE(terms[2]->field, EntrySearcher::Field::Username);
QCOMPARE(terms[2]->word, QString("user"));

QCOMPARE(terms[3]->field, EntrySearcher::Password);
QCOMPARE(terms[3]->field, EntrySearcher::Field::Password);
QCOMPARE(terms[3]->word, QString("test me"));

QCOMPARE(terms[4]->field, EntrySearcher::Undefined);
QCOMPARE(terms[4]->field, EntrySearcher::Field::Undefined);
QCOMPARE(terms[4]->word, QString("noquote"));

// Test wildcard and regex search terms
terms = m_entrySearcher.parseSearchTerms("+url:*.google.com *user:\\d+\\w{2}");

QCOMPARE(terms.length(), 2);

QCOMPARE(terms[0]->field, EntrySearcher::Url);
QCOMPARE(terms[0]->field, EntrySearcher::Field::Url);
QCOMPARE(terms[0]->regex.pattern(), QString("^.*\\.google\\.com$"));

QCOMPARE(terms[1]->field, EntrySearcher::Username);
QCOMPARE(terms[1]->field, EntrySearcher::Field::Username);
QCOMPARE(terms[1]->regex.pattern(), QString("\\d+\\w{2}"));
}

0 comments on commit 3b993ef

Please sign in to comment.