• Bug#1064341: colorized-logs: ansi2txt/ansi2html turn sgr0 into B instea

    From Adam Borowski@21:1/5 to Paul Wise on Tue Feb 20 11:20:01 2024
    Control: clone -1 -2
    Control: retitle -2 tput sgr0 adds uncalled-for codes
    Control: reassign -2 ncurses-bin

    On Tue, Feb 20, 2024 at 04:15:30PM +0800, Paul Wise wrote:
    ansi2txt/ansi2html turn sgr0 into 'B' instead of an empty string.

    $ echo $TERM
    xterm-256color

    $ tput sgr0 | hd
    00000000 1b 28 42 1b 5b 6d |.(B.[m|

    Here's the culprit. The code you asked for is "\e[0m" -- shortenable to non-canonical but valid "\e[m", which is the second half of tput's output.

    What you did not ask for, is "\e(B", which is not allowed in UTF-8 mode,
    and in non-Unicode world would switch to an ancient "US" charset.

    Putting aside arguments if this code is allowed or not (eg. the author of
    Putty has strong feelings on the matter), it's very clearly not what you
    asked for, thus the real bug is on tput's side.

    I'm reassigning to ncurses-bin as I believe that terminfo is merely an implementation detail here -- and a grossly obsolete one as the very concept
    of terminfo has stopped working by mid-1980's -- but ncurses-bin and ncurses-base come from the same source package so this hardly matters.

    Thus:
    "tput sgr0" should produce sgr0, not setusg0 sgr0.

    ---------------------------------------------------------------------------

    There's a second bug, though, this time on my side:

    $ tput sgr0 | ansi2txt ; echo
    B

    $ tput sgr0 | ansi2html --no-header
    <pre style="color:#bbb;white-space:pre-wrap;word-wrap:break-word;overflow-wrap:break-word">B</pre>

    When the text being parsed contains G0/G1 settings, whether intentional or
    not, they should be recognized and either implemented or ignored. ansi2txt promises to remove all ANSI codes, not merely ones that would make sense in
    the given context.

    It's probably not worth the effort to implement charset conversions anymore
    as non-Unicode is thoroughly dead by now; I'll thus ignore these codes.

    I guess other codes should be looked at, too...


    Meow!
    --
    ⢀⣴⠾⠻⢶⣦⠀
    ⣾⠁⢠⠒⠀⣿⡁
    ⢿⡄⠘⠷⠚⠋⠀ Quis trollabit ipsos trollos?
    ⠈⠳⣄⠀⠀⠀⠀

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)