Merge branch 'develop'

Conflicts:
	src/core/Tools.cpp
	src/sshagent/SSHAgent.cpp
This commit is contained in:
Jonathan White 2018-12-30 16:32:57 -05:00
commit 21de6f6163
No known key found for this signature in database
GPG key ID: 440FC65F2E0C6E01
57 changed files with 1296 additions and 395 deletions

View file

@ -28,6 +28,7 @@
#include <QLocale>
#include <QRegularExpression>
#include <QStringList>
#include <QUuid>
#include <cctype>
#ifdef Q_OS_WIN
@ -38,23 +39,6 @@
#include <time.h> // for nanosleep()
#endif
#include "config-keepassx.h"
#if defined(HAVE_RLIMIT_CORE)
#include <sys/resource.h>
#endif
#if defined(HAVE_PR_SET_DUMPABLE)
#include <sys/prctl.h>
#endif
#ifdef HAVE_PT_DENY_ATTACH
// clang-format off
#include <sys/types.h>
#include <sys/ptrace.h>
// clang-format on
#endif
namespace Tools
{
QString humanReadableFileSize(qint64 bytes, quint32 precision)
@ -197,34 +181,37 @@ namespace Tools
}
}
// Escape common regex symbols except for *, ?, and |
auto regexEscape = QRegularExpression(R"re(([-[\]{}()+.,\\\/^$#]))re");
// Escape common regex symbols except for *, ?, and |
auto regexEscape = QRegularExpression(R"re(([-[\]{}()+.,\\\/^$#]))re");
QRegularExpression convertToRegex(const QString& string, bool useWildcards, bool exactMatch, bool caseSensitive)
{
QString pattern = string;
QRegularExpression convertToRegex(const QString& string, bool useWildcards, bool exactMatch, bool caseSensitive)
{
QString pattern = string;
// Wildcard support (*, ?, |)
if (useWildcards) {
pattern.replace(regexEscape, "\\\\1");
pattern.replace("*", ".*");
pattern.replace("?", ".");
// Wildcard support (*, ?, |)
if (useWildcards) {
pattern.replace(regexEscape, "\\\\1");
pattern.replace("*", ".*");
pattern.replace("?", ".");
}
// Exact modifier
if (exactMatch) {
pattern = "^" + pattern + "$";
}
auto regex = QRegularExpression(pattern);
if (!caseSensitive) {
regex.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
}
return regex;
}
// Exact modifier
if (exactMatch) {
pattern = "^" + pattern + "$";
QString uuidToHex(const QUuid& uuid) {
return QString::fromLatin1(uuid.toRfc4122().toHex());
}
auto regex = QRegularExpression(pattern);
if (!caseSensitive) {
regex.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
}
return regex;
}
Buffer::Buffer()
: raw(nullptr)
, size(0)
@ -250,5 +237,4 @@ QRegularExpression convertToRegex(const QString& string, bool useWildcards, bool
return QByteArray(reinterpret_cast<char*>(raw), size );
}
} // namespace Tools