From 1d8a342304ce2090340748dae51999d20f6fc6d5 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Sat, 15 Aug 2015 11:15:58 +0200 Subject: check sendFile is actually given a full JID --- src/client/QXmppTransferManager.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/client/QXmppTransferManager.cpp') diff --git a/src/client/QXmppTransferManager.cpp b/src/client/QXmppTransferManager.cpp index 0616163d..e32aded7 100644 --- a/src/client/QXmppTransferManager.cpp +++ b/src/client/QXmppTransferManager.cpp @@ -1282,17 +1282,19 @@ void QXmppTransferManager::_q_jobStateChanged(QXmppTransferJob::State state) emit jobStarted(job); } -/// Send file to a remote party. +/// Sends the file at \a filePath to a remote party. /// /// The remote party will be given the choice to accept or refuse the transfer. /// +/// Returns 0 if the \a jid is not valid or if the file at \a filePath cannot be read. +/// /// \note The recipient's \a jid must be a full JID with a resource, for instance "user@host/resource". /// QXmppTransferJob *QXmppTransferManager::sendFile(const QString &jid, const QString &filePath, const QString &description) { - if (jid.isEmpty()) { - warning("Refusing to send file to an empty jid"); + if (QXmppUtils::jidToResource(jid).isEmpty()) { + warning("The file recipient's JID must be a full JID"); return 0; } @@ -1333,10 +1335,12 @@ QXmppTransferJob *QXmppTransferManager::sendFile(const QString &jid, const QStri return job; } -/// Send file to a remote party. +/// Sends the file in \a device to a remote party. /// /// The remote party will be given the choice to accept or refuse the transfer. /// +/// Returns 0 if the \a jid is not valid. +/// /// \note The recipient's \a jid must be a full JID with a resource, for instance "user@host/resource". /// @@ -1345,8 +1349,8 @@ QXmppTransferJob *QXmppTransferManager::sendFile(const QString &jid, QIODevice * bool check; Q_UNUSED(check); - if (jid.isEmpty()) { - warning("Refusing to send file to an empty jid"); + if (QXmppUtils::jidToResource(jid).isEmpty()) { + warning("The file recipient's JID must be a full JID"); return 0; } -- cgit v1.2.3