Fix receiving files with invalid URL characters
Summary: QUrl constructor assumes the string passed is already encoded so we need to pass it through setPath and QUrl::DecodedMode. Test Plan: sent a file with a weird character Reviewers: #kde_connect, jeanv Reviewed By: jeanv Differential Revision: https://phabricator.kde.org/D7224
This commit is contained in:
parent
815c2fe910
commit
28f11bd5c9
1 changed files with 4 additions and 3 deletions
|
@ -87,13 +87,14 @@ bool SharePlugin::receivePackage(const NetworkPackage& np)
|
||||||
qCDebug(KDECONNECT_PLUGIN_SHARE) << "File transfer";
|
qCDebug(KDECONNECT_PLUGIN_SHARE) << "File transfer";
|
||||||
|
|
||||||
if (np.hasPayload()) {
|
if (np.hasPayload()) {
|
||||||
//qCDebug(KDECONNECT_PLUGIN_SHARE) << "receiving file";
|
|
||||||
const QString filename = np.get<QString>(QStringLiteral("filename"), QString::number(QDateTime::currentMSecsSinceEpoch()));
|
const QString filename = np.get<QString>(QStringLiteral("filename"), QString::number(QDateTime::currentMSecsSinceEpoch()));
|
||||||
const QUrl dir = destinationDir().adjusted(QUrl::StripTrailingSlash);
|
const QUrl dir = destinationDir().adjusted(QUrl::StripTrailingSlash);
|
||||||
QUrl destination(dir.toString() + '/' + filename);
|
QUrl destination(dir);
|
||||||
|
destination.setPath(dir.path() + '/' + filename, QUrl::DecodedMode);
|
||||||
if (destination.isLocalFile() && QFile::exists(destination.toLocalFile())) {
|
if (destination.isLocalFile() && QFile::exists(destination.toLocalFile())) {
|
||||||
destination = QUrl(dir.toString() + '/' + KIO::suggestName(dir, filename));
|
destination.setPath(dir.path() + '/' + KIO::suggestName(dir, filename), QUrl::DecodedMode);
|
||||||
}
|
}
|
||||||
|
// qCDebug(KDECONNECT_PLUGIN_SHARE) << "receiving file" << filename << "in" << dir << "into" << destination;
|
||||||
|
|
||||||
FileTransferJob* job = np.createPayloadTransferJob(destination);
|
FileTransferJob* job = np.createPayloadTransferJob(destination);
|
||||||
job->setOriginName(device()->name() + ": " + filename);
|
job->setOriginName(device()->name() + ": " + filename);
|
||||||
|
|
Loading…
Reference in a new issue