Bug 391291 - Part of filename function does not count special characters
Summary: Part of filename function does not count special characters
Status: RESOLVED FIXED
Alias: None
Product: krename
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Heiko Becker
URL:
Keywords: junior-jobs
Depends on:
Blocks:
 
Reported: 2018-03-02 12:34 UTC by Peter Mühlenpfordt
Modified: 2018-04-21 16:39 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Example "part of filename" screenshot (15.46 KB, image/png)
2018-03-02 12:34 UTC, Peter Mühlenpfordt
Details

Note You need to log in before you can comment on or make changes to this bug.
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