Commit 2fdac221 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.
parent 9230eca2
......@@ -19,6 +19,7 @@
#include <QUrl>
#include <QDir>
#include <QDebug>
#include <QRegularExpression>
using namespace KWallet;
......@@ -89,10 +90,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