Use QRegularExpression instead of deprecated QRegExp

Now it follows closely the definition of wildcard for glob patterns.
The backslash (\) character is not an escape char in this context.
In order to match one of the special characters, place it in square
brackets (for example, [?]).
This commit is contained in:
Vladimir Golovnev (Glassez)
2021-03-14 18:11:23 +03:00
committed by sledgehammer999
parent a4a54ce712
commit 3b748178c2
11 changed files with 53 additions and 32 deletions

View File

@@ -38,7 +38,7 @@
#include <QMimeDatabase>
#include <QMimeType>
#include <QNetworkCookie>
#include <QRegExp>
#include <QRegularExpression>
#include <QUrl>
#include "base/algorithm.h"
@@ -693,7 +693,7 @@ bool WebApplication::validateHostHeader(const QStringList &domains) const
// try matching host header with domain list
for (const auto &domain : domains)
{
QRegExp domainRegex(domain, Qt::CaseInsensitive, QRegExp::Wildcard);
const QRegularExpression domainRegex {Utils::String::wildcardToRegexPattern(domain), QRegularExpression::CaseInsensitiveOption};
if (requestHost.contains(domainRegex))
return true;
}