Lister doesn't switch to plugin when HTML with UTF-8 is shown

Bug reports will be moved here when the described bug has been fixed

Moderators: white, Hacker, petermad, Stefan2

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

Lister doesn't switch to plugin when HTML with UTF-8 is shown

Post by *Dalai »

Hi everyone.

First of all, I'm not sure if this is a bug, but it certainly is a curious behavior that petermad reported yesterday viewtopic.php?p=445195#p445195

Steps to reproduce:
  1. Start TC with a clean INI
  2. Install a Lister plugin that shows HTML files, e.g. HTMLView (there is a newer version 1.2.6 but I can't find a public download source right now)
  3. "Define view method by file type" in the following way:

    Code: Select all

    [ListerModes]
    0exts=*.htm *.html
    0fields=5,htmlview.wlx
  4. Save the following code as an HTML file and open it in Lister:

    Code: Select all

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Some title</title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    </head>
    
    <body>
    There's no content here.
    </body>
    </html>
  5. Notice Lister's Encoding menu is disabled because it shows UTF-8 content. This is expected.
  6. Press the 4 key to switch to the plugin - Lister doesn't do anything.
  7. Press the 5 key to disable UTF-8 option. Notice the Encoding menu gets enabled (as expected).
  8. Press 4 again - Lister now switches to the plugin.
One more observation I made: If, in step 6, the HTML file is long enough and fully scrolled down, Lister does something when the 4 key is pressed: it scrolls the file to the top.

If the HTML file doesn't specify charset="utf-8" but something else like charset="iso-8859-1" instead, the switch to the plugin works immediately. The issue isn't within the Lister plugin. Something prevents Lister from switching to the plugin, but that something could be intentional, I don't know.

The same observations can be made in older TC versions like 10.52, maybe it's always been there since the introduction of "Define view method by file type".

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

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
AntonyD
Power Member
Power Member
Posts: 1249
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: Lister doesn't switch to plugin when HTML with UTF-8 is shown

Post by *AntonyD »

Save the following code as an HTML file
in which encoding?
#146217 personal license
User avatar
Dalai
Power Member
Power Member
Posts: 9393
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Lister doesn't switch to plugin when HTML with UTF-8 is shown

Post by *Dalai »

ANSI or UTF-8 with or without BOM - it doesn't really matter. Lister automatically detects it as UTF-8 even if the file doesn't have a BOM.

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

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
AntonyD
Power Member
Power Member
Posts: 1249
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: Lister doesn't switch to plugin when HTML with UTF-8 is shown

Post by *AntonyD »

Install a Lister plugin that shows HTML files, e.g. HTMLView (there is a newer version 1.2.6 but I can't find a public download source right now)
So maybe it's more correctly will be to use modern plug https://github.com/rg-software/wlx-markdown-viewer which incorporate inside itself all abilities from outdated HTMLView?
BUT if we want to use and test exactly 1.2.6 - here it is: https://madsenworld.dk/tcmd/plugins/wlx_htmlview_1.2.6.zip

hmmm.... btw I found one pascal/lazarus repo: https://github.com/BerndGabriel/HtmlViewer
looks promising? maybe some one can incorporated it also as a plug - or Mr.Ghisler will replace current internal code for rendering the HTML code by this one...
#146217 personal license
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Lister doesn't switch to plugin when HTML with UTF-8 is shown

Post by *ghisler(Author) »

This line instructs TC to switch to mode 5 when you press '4', and then to plugin htmlview.wlx when you press '4' again:
0fields=5,htmlview.wlx
But since you are in mode 5+7, pressing '4' can't do anything. It has nothing to do with encoding.
Author of Total Commander
https://www.ghisler.com
User avatar
Dalai
Power Member
Power Member
Posts: 9393
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Lister doesn't switch to plugin when HTML with UTF-8 is shown

Post by *Dalai »

2AntonyD
It just needs to be any Lister plugin capable of showing HTML files. It doesn't matter which one or if it's an up-to-date one.

ghisler(Author) wrote: 2023-11-17, 10:43 UTCBut since you are in mode 5+7, pressing '4' can't do anything.
So there are actually two modes: 5 and 5+7, just as in Lister's Options menu. How should the mode be defined to make this work properly? These variants don't work

Code: Select all

5+7,htmlview.wlx
7,htmlview.wlx
4i,htmlview.wlx
Phrased another way: How to define mode 5+7 in these [ListerModes]?
It has nothing to do with encoding.
Well, maybe not the encoding itself, but it does have to do with UTF-8 detection. I'm not saying that it's wrong that such a file is detected and shown as UTF-8.

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

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Lister doesn't switch to plugin when HTML with UTF-8 is shown

Post by *ghisler(Author) »

Phrased another way: How to define mode 5+7 in these [ListerModes]?
You can't.
While in mode 5+7, when you press '4' TC will see that it isn't in mode 5 alone and try to apply mode 5. But mode 5 auto-detects UTF-8 again and switches to mode 5+7 automatically.

What I could do is detect mode 5+7 as the same as mode 5 alone when you press '4'.
Author of Total Commander
https://www.ghisler.com
User avatar
Dalai
Power Member
Power Member
Posts: 9393
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Lister doesn't switch to plugin when HTML with UTF-8 is shown

Post by *Dalai »

ghisler(Author) wrote: 2023-11-17, 11:26 UTCWhat I could do is detect mode 5+7 as the same as mode 5 alone when you press '4'.
That would probably a good idea, especially considering the fact that Lister's Options menu shows a checkmark in front of mode 5 (and mode 7). I hope such a change doesn't have any side-effects.

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

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
petermad
Power Member
Power Member
Posts: 14809
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Lister doesn't switch to plugin when HTML with UTF-8 is shown

Post by *petermad »

What I could do is detect mode 5+7 as the same as mode 5 alone when you press '4'.
That sounds like a good idea :-)
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Lister doesn't switch to plugin when HTML with UTF-8 is shown

Post by *ghisler(Author) »

This should be fixed in Total Commander 11.03 RC1, please check it!
Author of Total Commander
https://www.ghisler.com
User avatar
Dalai
Power Member
Power Member
Posts: 9393
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Lister doesn't switch to plugin when HTML with UTF-8 is shown

Post by *Dalai »

Code: Select all

17.11.23 Fixed: Lister, view UTF-8 encoded HTML: couldn't switch to plugin with '4' with [ListerModes], 0fields=5,htmlview.wlx (32/64)
Confirm the fix for 11.03 RC1 32-bit. I haven't tested the 64-bit version yet.

[EDIT]
Fix also confirmed for the 64-bit version.
[/EDIT]
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Lister doesn't switch to plugin when HTML with UTF-8 is shown

Post by *ghisler(Author) »

Thanks!

Moderator message

Moved to fixed bugs
Author of Total Commander
https://www.ghisler.com
Post Reply