Character removal bug in 4.9.3

All your suggestions, requests and ideas for future development
Post Reply
Xiphan
Posts: 9
Joined: 21 May 2020, 20:45

Character removal bug in 4.9.3

Post by Xiphan »

I just noticed a rather unique bug that was introduced in 4.9.3 that did not exist in 4.9.2. I'm not sure if this is intentional behaviour or a new safety feature but I just used the latest version to test a change to my format expression on the show Person of Interest. The reason I say unique is because the name of episode S05E12 is .exe.

In 4.9.2 it has no problem naming the file .exe as the format's extension still comes after this:

Image

But in 4.9.3 it removes the period before the exe:

Image
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Character removal bug in 4.9.3

Post by rednoah »

What is your custom format?
:idea: Please read the FAQ and How to Request Help.
Xiphan
Posts: 9
Joined: 21 May 2020, 20:45

Re: Character removal bug in 4.9.3

Post by Xiphan »

rednoah wrote: 24 Feb 2021, 03:31 What is your custom format?

Code: Select all

S:/{n.sortName('$2, $1').replaceAll(/[:|]/, " - ")}/{episode.special ? 'Specials' : 'Season '+s}/{ext =~ /(?i)idx|sub|srt/ ? '/Subs/' : ''}/{n.colon(" - ")}{episode.regular ? {' '+s.pad(2)+'x'+episodes.collect{[it.episode]*.pad(2).join('x') }.join('-')} : ' 00x'+special.pad(2)} - {t.colon(" - ").removeIllegalCharacters().replacePart(' (Part $1)')}{fn =~ /(?i)extended/ ? ' (Extended Version)' : ''}{fn =~ /(?i)-thumb/ ? '-thumb' : ''}{'.'+lang.ISO2}
I'm wondering now if it could be the use of removeIllegalCharacters(), although it's strange that in 4.9.2 it doesn't remove the leading period and in 4.9.3 it does? :?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Character removal bug in 4.9.3

Post by rednoah »

{t} yields .exe as expected:

Code: Select all

{t}
After removing illegal characters the result is exe which is expected too (file names must not start with . because that denotes hidden files) but perhaps isn't exactly what you want in this particular use case:

Code: Select all

{t.removeIllegalCharacters()}

:arrow: You may prefer to explicitly specify exactly what you want to remove via custom regex:

Code: Select all

{t.removeAll(/[!?]/)}
:idea: Please read the FAQ and How to Request Help.
Xiphan
Posts: 9
Joined: 21 May 2020, 20:45

Re: Character removal bug in 4.9.3

Post by Xiphan »

rednoah wrote: 25 Feb 2021, 06:33 {t} yields .exe as expected:

Code: Select all

{t}
After removing illegal characters the result is exe which is expected too (file names must not start with . because that denotes hidden files) but perhaps isn't exactly what you want in this particular use case:

Code: Select all

{t.removeIllegalCharacters()}
Okay, so it was t.removeIllegalCharacters() causing this which I noticed also removes the trailing (or extra) periods from the filename because it changes B.S.O.D. to B.S.O.D

As for the filename beginning with a period there seems to be logic in the code for 4.9.2 that realises {t} is not the start of the file so it doesn't remove the leading period. Nevertheless...
rednoah wrote: 25 Feb 2021, 06:33 :arrow: You may prefer to explicitly specify exactly what you want to remove via custom regex:

Code: Select all

{t.removeAll(/[!?]/)}
I was actually using this custom regex previously, well an incorrect version of it which I have now replaced with n.colon(" - ") I think I was just experimenting with removeIllegalCharacters() to see what it does, but since I don't like what it does I will change my format back to custom regex. :lol:

As always thanks for your rapid response. ;)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Character removal bug in 4.9.3

Post by rednoah »

Xiphan wrote: 25 Feb 2021, 20:37 As for the filename beginning with a period there seems to be logic in the code for 4.9.2 that realises {t} is not the start of the file so it doesn't remove the leading period. Nevertheless...
Previous revisions just didn't account for leading . at all, allowing Linux and Mac users to accidentally create hidden files and folders (e.g. if the series name starts with . then series folder disappears) which is now fixed.


:idea: String.removeIllegalCharacters() can't know the context in which it is used. Internally, it's used for validating file names as best as possible, which now includes stripping leading . as well.
:idea: Please read the FAQ and How to Request Help.
Post Reply