diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-10-17 17:13:31 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-10-17 17:13:31 +0900 |
commit | f2f85ba093df5dcd991fd206af4d79d57f4c7fc8 (patch) | |
tree | bf2d31cd1640d9c315f00490dbeb13c821dcb386 /jobs/basejob.cpp | |
parent | 614917ad7c1c0beec847094369a2b3bd383562ca (diff) | |
download | libquotient-f2f85ba093df5dcd991fd206af4d79d57f4c7fc8.tar.gz libquotient-f2f85ba093df5dcd991fd206af4d79d57f4c7fc8.zip |
Avoid leaking access_token in the logs
Closes #102.
Diffstat (limited to 'jobs/basejob.cpp')
-rw-r--r-- | jobs/basejob.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp index 240192d9..eb78dec8 100644 --- a/jobs/basejob.cpp +++ b/jobs/basejob.cpp @@ -24,6 +24,7 @@ #include <QtNetwork/QNetworkRequest> #include <QtNetwork/QNetworkReply> #include <QtCore/QTimer> +#include <QtCore/QRegularExpression> //#include <QtCore/QStringBuilder> #include <array> @@ -79,6 +80,13 @@ inline QDebug operator<<(QDebug dbg, const BaseJob* j) return dbg << j->objectName(); } +QDebug QMatrixClient::operator<<(QDebug dbg, const BaseJob::Status& s) +{ + QRegularExpression filter { "(access_token)=[-_A-Za-z0-9]+" }; + return dbg << s.code << ':' + << QString(s.message).replace(filter, "\1=HIDDEN"); +} + BaseJob::BaseJob(HttpVerb verb, const QString& name, const QString& endpoint, const Query& query, const Data& data, bool needsToken) : d(new Private(verb, endpoint, query, data, needsToken)) @@ -331,10 +339,7 @@ void BaseJob::setStatus(Status s) { d->status = s; if (!s.good()) - { - qCWarning(d->logCat) << this << "status" << s.code - << ":" << s.message; - } + qCWarning(d->logCat) << this << "status" << s; } void BaseJob::setStatus(int code, QString message) |