[dolphin] [Bug 466814] New: dolphin rename file selects part of the extension when name contains composed glyphs (diacritics, emojis)

bugzilla_noreply at kde.org bugzilla_noreply at kde.org
Sat Mar 4 07:52:09 GMT 2023


https://bugs.kde.org/show_bug.cgi?id=466814

            Bug ID: 466814
           Summary: dolphin rename file selects part of the extension when
                    name contains composed glyphs (diacritics, emojis)
    Classification: Applications
           Product: dolphin
           Version: 22.08.2
          Platform: Other
                OS: Other
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: view-engine: general
          Assignee: dolphin-bugs-null at kde.org
          Reporter: kdebugs at toeai.com
                CC: kfm-devel at kde.org
  Target Milestone: ---

SUMMARY
Dolphin improperly counts characters when attempting to select everything but
the ".ext".

STEPS TO REPRODUCE
1. Make a file named "épée.txt"
[NB: each é is composed of U+0065 (lowercase letter e) plus U+0301 (combining
acute accent).  The filename does NOT use the precomposed character U+00E9.]
2. Select the file and hit F2 (or right-click and select Rename...)

OBSERVED RESULT
Dolphin selects "épée.t"

EXPECTED RESULT
Dolphin should select "épée"

SOFTWARE/OS VERSIONS
Kubuntu 22.10
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6

ADDITIONAL INFORMATION

Second example, but with emojis:
"zz❤️❤️.txt" (NB: each of the two hearts is composed of U+2764 followed by
U+FE0F)

Without looking at the code, I'm guessing someone did something naive like
QTextCursor.movePosition() by a certain number of characters.  The programmer
should understanding that Qt counts cursor positions in QChar (always 16-bit,
so sometimes partial characters), however movePosition jumps over
composed/joined characters as a unit, so neither setPosition() nor
movePosition() are suitable for placing the cursor at a given character offset.
 You must first encode the string you want to select as utf-16 and divide the
resulting length in bytes by 2.  This number is what you use to determine a
QChar offset which can be passed to setPosition.

[If done right, that should put you in front of the period (.) which is safe
enough.  In other contexts, you would want to also make sure that your moving
by x number of characters doesn't land you in the middle of a composed glyph. 
You can do that by using movePosition to advance 1 character and then again to
go back 1 character.  If you weren't in the middle of a glyph, this doesn't
move you, but if you were, it safely puts you in front of whatever you were
in.]

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the kfm-devel mailing list