Bug 391291

Summary: Part of filename function does not count special characters
Product: [Applications] krename Reporter: Peter Mühlenpfordt <devel>
Component: generalAssignee: Heiko Becker <heiko.becker>
Status: RESOLVED FIXED    
Severity: normal Keywords: junior-jobs
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Example "part of filename" screenshot

Description Peter Mühlenpfordt 2018-03-02 12:34:29 UTC
Created attachment 111136 [details]
Example "part of filename" screenshot

Using the part-of-filename function in KRename (e.g. [$1;5] or [$1-[length]]) does not count special characters like '&', '%', '#' and shortens the result by the number of these. If a special character is at the end of the filename-part '\' is inserted.

E.g.
[$2-[length]] "1234#6789.txt" -> "234#678.txt" (expected: "234#6789.txt")[$2-[length]] "12&&567.txt" -> "2&&5.txt" (expected: "2&&567.txt")
[$2;3] "123%56.txt" -> "23\.txt" (expected: "23%.txt")

Tested with KRename 4.0.9 (Kubuntu 17.10 packages) and 5.0.60 (git master).
Comment 1 Christoph Feck 2018-03-29 15:09:53 UTC
Indeed the findLength() function only uses name.length(), without first unescaping tokens.

https://cgit.kde.org/krename.git/tree/src/batchrenamer.cpp#n1064
Comment 2 Christoph Feck 2018-03-29 15:11:23 UTC
Similar issue for findPartStrings()...
Comment 3 Heiko Becker 2018-04-21 16:39:44 UTC
Git commit d9f23bd5dc9e87c9613136708dd93ff92ba9bc23 by Heiko Becker.
Committed on 21/04/2018 at 15:28.
Pushed by heikobecker into branch '5.0'.

Escape/unescape filenames with special characters

M  +10   -1    src/batchrenamer.cpp

https://commits.kde.org/krename/d9f23bd5dc9e87c9613136708dd93ff92ba9bc23