1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
From: Ibragimov Rinat <ibragimovrinat@mail.ru>
Subject: Fix longlink UTF-8 support in KTar
Bug: http://bugs.kde.org/show_bug.cgi?id=266141
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=612675
Last-Update: 2011-05-14
Forwarded: yes
Origin: other, http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=612675#5
Acked-By: Modestas Vainius <modax@debian.org>
tar archives have to use "longlink trick" to store names longer than 100 bytes.
KTar class has functions implementing longlink, but they check name length in
_characters_, not in bytes. For non-ASCII characters in UTF-8 length of string
in bytes and length in characters do not match. In my case file had
character-length less than 100 and byte-length greater than 100, so name simply
truncated. Such behavior can be observed on non-ASCII UTF-8 or any other
multibyte encoding. If file name is very long, resulting .tar may become
unreadable.
--- a/kio/kio/ktar.cpp
+++ b/kio/kio/ktar.cpp
@@ -750,7 +750,7 @@ bool KTar::doPrepareWriting(const QStrin
const QByteArray gname = group.toLocal8Bit();
// If more than 100 chars, we need to use the LongLink trick
- if ( fileName.length() > 99 )
+ if ( encodedFileName.length() > 99 )
d->writeLonglink(buffer,encodedFileName,'L',uname,gname);
// Write (potentially truncated) name
@@ -803,7 +803,7 @@ bool KTar::doWriteDir(const QString &nam
QByteArray gname = group.toLocal8Bit();
// If more than 100 chars, we need to use the LongLink trick
- if ( dirName.length() > 99 )
+ if ( encodedDirname.length() > 99 )
d->writeLonglink(buffer,encodedDirname,'L',uname,gname);
// Write (potentially truncated) name
@@ -855,9 +855,9 @@ bool KTar::doWriteSymLink(const QString
QByteArray gname = group.toLocal8Bit();
// If more than 100 chars, we need to use the LongLink trick
- if (target.length() > 99)
+ if (encodedTarget.length() > 99)
d->writeLonglink(buffer,encodedTarget,'K',uname,gname);
- if ( fileName.length() > 99 )
+ if ( encodedFileName.length() > 99 )
d->writeLonglink(buffer,encodedFileName,'L',uname,gname);
// Write (potentially truncated) name
|