[WFX] Different filenames in View and Copy

Please report only one bug per message!

Moderators: sheep, Hacker, Stefan2, white

Post Reply
User avatar
Dalai
Power Member
Power Member
Posts: 6753
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

[WFX] Different filenames in View and Copy

Post by *Dalai » 2019-04-25, 23:43 UTC

Hi there,

Although I'm posting this in the Bug reports section I'm not sure if this behavior can be called a bug, but it's unexpected nonetheless. To reproduce this, you need a WFX plugin that shows files with a slash in their name, e.g. my Services2 plugin.

View such a file (F3) (e.g. "TCP/IP NetBIOS Helper" in my Services2 plugin) and take a look at the filename used by TC to save the file. You'll see that the name only contains the part after the slash. Copy (F5) the same file to some local directory and you'll see that the filename is complete, i.e. also containing the part before the slash.

Full example for my Services2 plugin:

Code: Select all

Remote filename          function     Resulting local filename
TCP/IP NetBIOS Helper    F3 (View)    IP NetBIOS Helper[.Running]
TCP/IP NetBIOS Helper    F5 (Copy)    TCP_IP NetBIOS Helper[.Running]
The important thing is that this is not limited to or caused by my plugin. In the debugger I can see that TC provides different local filenames for F3 and F5 functions, although both of them call the same plugin function FsGetFile(W).

Why does TC provide different local filenames depending on which function in TC is used? This is irritating, unexpeced and probably one of the reasons why I thought TC would already replace invalid characters in filenames a couple of years ago.

BTW: This issue is a long-standing one; I can reproduce it even in TC 8.01.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups

User avatar
petermad
Power Member
Power Member
Posts: 8849
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

Re: [WFX] Different filenames in View and Copy

Post by *petermad » 2019-04-26, 18:20 UTC

I can confirm the bug.
License #524 (1994)
Danish Total Commander Translator
TC 9.5b3 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 (1903) 64bit, 'Everything' 1.4.1.935 (x64)
TC 3.0b12 on Android 6.0
Get: Extended Total Commander Menus | PHSM-Calendar

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 38170
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [WFX] Different filenames in View and Copy

Post by *ghisler(Author) » 2019-04-29, 14:02 UTC

It's not a bug, just a different method to sanitize file names (removing forbidden characters): When you press F3, the local file gets the last part of the name after the last slash or backslash. When you use copy, all forbidden characters are replaced by an underscore.
Author of Total Commander
http://www.ghisler.com

User avatar
Dalai
Power Member
Power Member
Posts: 6753
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: [WFX] Different filenames in View and Copy

Post by *Dalai » 2019-04-29, 18:46 UTC

ghisler(Author) wrote:
2019-04-29, 14:02 UTC
It's not a bug, just a different method to sanitize file names (removing forbidden characters): When you press F3, the local file gets the last part of the name after the last slash or backslash.
But why the difference? F3 passes one filename variant, F5 another and F3 in Synchronize directories uses the same as regular F5. I admit that in the end it's not a big deal because the filenames created with F3 are only temporary in nature (as opposed to F5/Copy), but that doesn't change the fact that it's irritating and unexpected that different values for the same filename are passed to the plugin.
When you use copy, all forbidden characters are replaced by an underscore.
Uh, then why the discussion in the linked thread a couple of years ago, where you and other users concluded that it's the plugin's job to sanitize the filenames? Furthermore, if TC already sanitizes the local filenames, why doesn't it pass the sanitized local filenames to the plugins instead of doing it afterwards? And even then, it's not consistent: colons and slashes are replaced before passed to a WFX plugin, but double quotes are not.

[EDIT]
TC's behavior can be a bigger problem: When a remote filename ends with a slash, TC passes a non-meaningful local filename to the plugin's FsGetFile function, i.e. ".000."
[/EDIT]

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups

User avatar
Dalai
Power Member
Power Member
Posts: 6753
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: [WFX] Different filenames in View and Copy

Post by *Dalai » 2019-05-03, 19:10 UTC

For the record, and to document TC's behavior for me and others, I cobbled together a list of all special characters in filenames for WFX plugins. The following table ONLY applies to FILES, NOT to directories! Currently I don't have the means and time to test that with directories.

Code: Select all

      | Replaced in
Char  | F3/View F5/Copy
----------------------
<     | Yes     Yes
>     | Yes     Yes
:     | Yes     Yes
|     | Yes     Yes
?     | Yes     Yes
*     | Yes     Yes
"     | Yes*    Yes*
/     | NO**    Yes
\     | ?       ?
*) TC 8.50+ replaces quotes, older versions do not. Unfortunately I haven't been able to find the according fix/change in TC's history.txt (probably because I used the wrong search terms).
**) TC doesn't replace the char but extracts and uses the part after the slash instead, see OP.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups

Post Reply