Manipulate bytes instead of characters
ClosedPublic

Authored by chinmoyr on May 21 2019, 1:07 PM.

Details

Summary

D21155 trucates a QString. Since most Linux FS specify filename limits in bytes, convert the url to
QByteArray and then truncate.

As for truncating a UTF-8 sequence in middle, will it have any noticeable impact?
After truncating, the url loses any meaning it had initially. So IMO a few characters
at the end which were initially not a part of the url don't make any difference.

Diff Detail

Repository
R241 KIO
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
chinmoyr created this revision.May 21 2019, 1:07 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptMay 21 2019, 1:07 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
chinmoyr requested review of this revision.May 21 2019, 1:07 PM

+1 from me, but if Thiago can take a look (about the issue of truncating in the middle of a multi-bytes utf8 characters) that'd be even better.

I cringe a little when you apply QFile to a URL, but this is probably safe enough.

LGTM

As for truncating UTF-8 multibyte sequences in the middle, when you convert back using QFile::decodeName, it'll be nonsensical. But I don't think it really matters since you're truncating and using the display string anyway, so you're already losing data. This wasn't a recoverable conversion anyway.

This revision was not accepted when it landed; it landed in state Needs Review.May 27 2019, 2:06 PM
This revision was automatically updated to reflect the committed changes.