Redact password from URL when displaying internal errors

This commit is contained in:
Martchus 2021-10-02 20:31:20 +02:00
parent 239d751342
commit 745082f357
2 changed files with 14 additions and 7 deletions

View File

@ -12,6 +12,20 @@ using namespace Data;
namespace QtGui {
/*!
* \brief Constructs a new error suitable for display purposes (password in \a url is redacted).
*/
InternalError::InternalError(const QString &message, const QUrl &url, const QByteArray &response)
: message(message)
, url(url)
, response(response)
, when(CppUtilities::DateTime::now())
{
if (!this->url.password().isEmpty()) {
this->url.setPassword(QStringLiteral("redacted"));
}
}
/*!
* \brief Returns whether the error is relevant. Only in this case a notification for the error should be shown.
* \todo Unify with SyncthingNotifier::isDisconnectRelevant().

View File

@ -27,13 +27,6 @@ struct SYNCTHINGWIDGETS_EXPORT InternalError {
CppUtilities::DateTime when;
};
inline InternalError::InternalError(const QString &message, const QUrl &url, const QByteArray &response)
: message(message)
, url(url)
, response(response)
, when(CppUtilities::DateTime::now())
{
}
} // namespace QtGui
#endif // SYNCTHINGWIDGETS_INTERNAL_ERROR_H