Git commit 6738a8b2f71c527f30a624b0b560f79d992715d3 by Christoph Feck.
Committed on 21/05/2019 at 11:05.
Pushed by cfeck into branch 'master'.

[kioslave/file] Add a codec for legacy filenames

UNIX filenames can contain any bytes (except \0 and /).
Qt's QFile::decodeName() calls QString::fromLocal8Bit(), assuming that all
filesystems use the system's locale encoding. For filenames that have been
created with a different encoding, and have not yet been converted (e.g. using
convmv), this creates non-reversible U+FFFD (REPLACEMENT CHARACTER)
code points in the filenames.

For example, some old-style archives might not contain any information about
the encoding of the filenames, and even today archivers extract them without
trying to convert to the locale's encoding.

While full support for those filenames is not needed, Dolphin should at least
be able to delete, rename, and move those files. Since all actual (local) file
handling is done inside the file kioslave, patching Dolphin will not help.

This code is a near verbatim copy of the code we had in kdelibs, written by
Szókovács Róbert. Only minor adaptions to Qt5 were done. It decodes invalid
bytes as U+10FExx from Plane 16 (Supplementary Private Use Area-B) to be able
to encode them later.

Dolphin could detect filenames with those characters, and either mark them
(by color or overlay icon), or even automatically offer to rename them.
Related: bug 204768

TEST PLAN

touch "/tmp/test-"$'\377'".txt"
dolphin /tmp

Copying and deleting a test file worked with this code, failed without.

Reviewers: dfaure, Frameworks, Dolphin

Reviewed by: dfaure

Differential Revision: https://phabricator.kde.org/D18161

M  +1    -1    src/ioslaves/file/CMakeLists.txt
M  +8    -0    src/ioslaves/file/file.cpp
A  +174  -0    src/ioslaves/file/legacycodec.cpp     [License: LGPL (v2+)]
A  +66   -0    src/ioslaves/file/legacycodec.h     [License: LGPL (v2+)]

https://commits.kde.org/kio/6738a8b2f71c527f30a624b0b560f79d992715d3

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/510018

Title:
  Cannot delete file with bad filename

To manage notifications about this bug go to:
https://bugs.launchpad.net/kde-baseapps/+bug/510018/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to