Internal Associations don't work with extensions containing control characters

Please report only one bug per message!

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Internal Associations don't work with extensions containing control characters

Post by *DrShark »

Internal association does not work (file type icon is not applied and associated program does not start) if extension name part has present a control character like left-to-right mark.

For example, on one of my read-only drives I have many files in PDF format with extension ".pdf‎" (the LRM character is between "f" and trailing quote mark). If in internal Asscociations I add such a new extension, change file type icon and set a program to open it, the association is created, but in TC I see blank white icon and after pressing Enter on file with such extension I see Windows dialog which asks to chosse the program which I want to use to open that file.

Furthermore, internal association which uses masks/wildcards, like *.pdf* or *.pdf? is not applied for such files either.

The character itself is not a problem for opening a file in desired program, e.g. if from TC's command line to launch:

d:\progra~1\sandbo~1\start.exe %HOMEDRIVE%progra~1\adobe\acroba~1.0\Acrobat\Acrobat.exe /a zoom=100 "file.pdf‎"

Adobe Acrobat opens the "file.pdf‎" file fine.

(off top: an example with Sanboxie is used because here launching Acrobat this way helps to avoid known Acrobat's "Fatal Error Acrobat failed to load its Core DLL", maybe someopne will find this info helpful).
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48012
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Internal Associations don't work with extensions containing control characters

Post by *ghisler(Author) »

Yes, files with LRM characters are filtered out on purpose because it is sometimes used by malware, e.g. to make a file named fdp.exe appear as .exe.pdf, to trick the user to open it.
Author of Total Commander
https://www.ghisler.com
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Re: Internal Associations don't work with extensions containing control characters

Post by *DrShark »

ghisler(Author) wrote: 2020-11-06, 14:25 UTCYes, files with LRM characters are filtered out on purpose because it is sometimes used by malware, e.g. to make a file named fdp.exe appear as .exe.pdf, to trick the user to open it.
Where exactly should I put LRM char in the name fdp.exe so in Explorer it will look like exe.pdf? So far I cannot get this by putting LRM in the start, end of name, before or after the dot (tried on Windows 7 32 bit)...
Anyway, what is the point to filter control characters in Internal Associations, where users usually intentionally associate files with programs, so associated files aren't launched as executables?
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
User avatar
elgonzo
Power Member
Power Member
Posts: 866
Joined: 2013-09-04, 14:07 UTC

Re: Internal Associations don't work with extensions containing control characters

Post by *elgonzo »

DrShark wrote: 2020-12-09, 10:21 UTC Where exactly should I put LRM char in the name fdp.exe so in Explorer it will look like exe.pdf?
Nowhere. (I guess Christians comment was meant more about directional formatting characters in general, not specifically about LRM.)

Unless you are on a Hebrew, Arabic or other naturally right-to-left locale, your OS is already operating in LRM mode/level. Thus applying LRM will have no visible effect (as it attempts entering LRM mode/level that is already active for both your system in general and for latin letters/script)

Now, RLM (Right-to-Left-Mark; U+200F) would seem like the logical choice. Normally, when applying to a text block within a larger text, the RLM formatting char should be put at the right side of the text block being formatted right-to-left, like:

Code: Select all

fdp.exe[RLM]
However, since there is no text block embedded within a larger text here, perhaps try placing [RLM] at the beginning of the text instead:

Code: Select all

[RLM]fdp.exe
(I can't be arsed to double-check the whole spec. about the specifics of RLM behavior, as it should be easy to simply try it out ;) )


If RLM does not work, there are still explicit formatting characters such as RLO, LRO, RLI, LRI, PDI, etc. But i can't tell whether Explorer respects or ignores such formatting chars altogether, as i haven't tried it myself. Here their Unicode/UTF-16 byte codes:

Code: Select all

LRO   U+202D    (Left-to-Right-Override)
RLO   U+202E    (Right-to-Left-Override)

LRI   U+2066    (Left-to-Right-Isolate)
RLI   U+2067    (Right-to-Left-Isolate)
PDI   U+2069    (Pop Directional Isolate)
Using RLO, try composing your file name like this:

Code: Select all

[RLO]fdp.exe
or, with RLI

Code: Select all

[RLI]fdp.exe[PDI]
(Not sure if the [PDI] would be strictly necessary here as it is at the very end of the text.)


More details and further headache-inducing information can be found in the Unicode Bidirectional Algorithm spec at: http://unicode.org/reports/tr9/

Anyways, my apologies for the slight detour. Back to topic... :)
Begrudgingly back to Windows... now 11... sigh... but i have no nerve for Linux desktop anymore...
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Re: Internal Associations don't work with extensions containing control characters

Post by *DrShark »

elgonzo wrote: 2020-12-09, 11:49 UTCHowever, since there is no text block embedded within a larger text here, perhaps try placing [RLM] at the beginning of the text instead:

Code: Select all

[RLM]fdp.exe
Using RLO, try composing your file name like this:

Code: Select all

[RLO]fdp.exe
OK, this way the name looks like "exe.pdf" in Explorer's file listing and while file renaming, though the icon for "exe" extension is used and when rename field opens, the part of name without actual extension is autoselected.

In TC, it depends on function which operates with the name and TC options, so, for example:
- in Shift+F6 inplace rename, F5/F6 copy/move dialogs, it looks like "exe.pdf";
- in file listing it depends on value of "Aligned extension" parameter from [Configuretion] section of wincmd.ini:
* with default

Code: Select all

[Configuration]
Aligned extension=1
the name looks like "pdf.exe";
* with default

Code: Select all

[Configuration]
Aligned extension=0
the name looks like " fdp.exe", where the sign which looks like a space before the name is actually the RLO char, so this way TC indicates its presence.
No matter how the name looks like, TC uses EXE file type icon for it (though different from one used for EXE in Explorer).

So if such character is supposed to be filtered out, I guess it should happen in file listing, so the name, when Aligned extension=1, should look the same way as when Aligned extension=0.

I still don't see any poing to filtering it out in Internal Associations.
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Re: Internal Associations don't work with extensions containing control characters

Post by *DrShark »

It's possibile that there was no bug in TC and I messed up somewhere when configring the internal associations...
I just rechecked, and right now both wildcard method:

Code: Select all

[Associations]
Filter1=*.pdf*
Filter1_open=d:\install\sandbo~1\start.exe %HOMEDRIVE%progra~1\adobe\acroba~1.0\Acrobat\Acrobat.exe /a zoom=100 "%1"
Filter1.icon=""%programfiles%\Adobe\Acrobat 11.0\Acrobat\AcroRd32.exe""
and direct *.pdf[LRM] associations work just fine in both TC 9.51 and 10.00:

Code: Select all

[Associations]
Filter1=*.pdf‎
Filter1_open=d:\install\sandbo~1\start.exe %HOMEDRIVE%progra~1\adobe\acroba~1.0\Acrobat\Acrobat.exe /a zoom=100 "%1"
Filter1.icon=""%programfiles%\Adobe\Acrobat 11.0\Acrobat\AcroRd32.exe""
I guess the topic can be moved to English forum...
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
Post Reply