Skip to content

Commit

Permalink
Properly convert filename to bytearray when sending over portal
Browse files Browse the repository at this point in the history
We should be using QFile::encodeName() to properly convert filenames
from string to bytearray. This takes user's locale into account.

Change-Id: I090f73f21feb73af166e88baa0e7f4a595cdb25b
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
grulja committed Feb 21, 2019
1 parent 06b29a6 commit 1d3a162
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include <QDBusPendingCallWatcher>
#include <QDBusPendingReply>

#include <QFile>
#include <QMetaType>
#include <QMimeType>
#include <QMimeDatabase>
Expand Down Expand Up @@ -181,10 +182,10 @@ void QXdgDesktopPortalFileDialog::openPortal()

if (d->saveFile) {
if (!d->directory.isEmpty())
options.insert(QLatin1String("current_folder"), d->directory.toLatin1().append('\0'));
options.insert(QLatin1String("current_folder"), QFile::encodeName(d->directory).append('\0'));

if (!d->selectedFiles.isEmpty())
options.insert(QLatin1String("current_file"), d->selectedFiles.first().toLatin1().append('\0'));
options.insert(QLatin1String("current_file"), QFile::encodeName(d->selectedFiles.first()).append('\0'));
}

// Insert filters
Expand Down

0 comments on commit 1d3a162

Please sign in to comment.