KAutoSaveFile breaks if source file name contains a space!
ClosedPublic

Authored by mardelle on Oct 1 2017, 9:25 AM.

Details

Summary

KAutoSaveFile does not correctly handle simple characters like spaces in file names!!!
When creating a stale file (backup file) , to determine the file name it uses:
in tempFileName(), line 83:
return QString::fromLatin1(QUrl::toPercentEncoding(name).constData());

So the filename is encoded using percent encoding. But when checking for an existing backup file, it does:
in extractManagedFilePath, line 180:
managedFileName.setPath(QUrl::fromPercentEncoding(encodedPath) + QLatin1Char('/') + QFileInfo(staleFileName.left(sepPos)).fileName());

So the path part is correctly restored from percent encoding, but the filename part is not decoded.
So we end up comparing "my file" with "my%20file" and the stale file is not correctly identified!

Test Plan

Project files with space in their name in Kdenlive now have crash recovery working

Diff Detail

Repository
R244 KCoreAddons
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mardelle created this revision.Oct 1 2017, 9:25 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptOct 1 2017, 9:25 AM

I don't know the code too much, but would it be possible to add an autotest for this?

mardelle updated this revision to Diff 20216.Oct 1 2017, 9:22 PM

Added test to check stale file is correctly found

cfeck added a subscriber: cfeck.Oct 17 2017, 7:43 PM
cfeck added inline comments.
autotests/kautosavefiletest.cpp
87

saveFile.write("testdata") is sufficient.

dfaure added a subscriber: dfaure.Nov 1 2017, 8:31 PM

Thanks for the fix and autotest !

autotests/kautosavefiletest.cpp
83

Should use QDir::tempPath() for portability.

mardelle updated this revision to Diff 21868.Nov 4 2017, 3:51 PM
mardelle marked 2 inline comments as done.
dfaure accepted this revision.Nov 5 2017, 8:08 AM
This revision is now accepted and ready to land.Nov 5 2017, 8:08 AM
This revision was automatically updated to reflect the committed changes.