Commit 7f03f218 authored by Nicolas Fella's avatar Nicolas Fella

[plugins/kio-webdav] Fix realm extraction

The current regex didn't take into account that the realm may contain a space or have the charset specified.
This resulted in an empty realm being extracted and thus a wrong entry written into the wallet.

(cherry picked from commit 2fdac221)
parent ab8ba5c9
......@@ -31,6 +31,7 @@
#include <QUrl>
#include <QDir>
#include <QDebug>
#include <QRegularExpression>
using namespace KWallet;
......@@ -101,10 +102,14 @@ void CreateNetAttachJob::getRealm()
void CreateNetAttachJob::gotRealm(KJob *job)
{
KIO::TransferJob *hJob = qobject_cast<KIO::TransferJob*>(job);
QRegExp rx(QStringLiteral("www-authenticate: Basic realm=\"(\\S+)\"\n"));
QRegularExpression rx(QStringLiteral("www-authenticate: Basic realm=\"([^\"]+)\""));
Q_ASSERT(rx.isValid());
QString headers = hJob->metaData().value(QStringLiteral("HTTP-Headers"));
if (rx.indexIn(headers) != -1) {
m_realm = rx.cap(1);
auto match = rx.match(headers);
if (match.hasMatch()) {
m_realm = match.captured(1);
}
createDesktopFile(hJob->url());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment