HTML tags not closed properly if \r (carriage return) is in the input
ansifilter version: latest commit ( 5605ad0b)
OS: linux
The problem becomes apparent when there are carriage returns (\r) is in the input, not followed by new lines (\n) e.g.
$ echo -e '\rHello World!' | ansifilter --html --fragment
<span style="color:#000000;">Hello World!
The span
tag isn't closed.
I'm processing output of a command that prints a "spinning dash" while working, followed by a message, something like:
|\r/\r-\r\\\r\033[32mDone!
ansifilter produces following output:
<span style="color:#000000;"><span style="color:#00cd00;">Done!
</span>
While dashes are properly removed, there is this bogus <span style="color:#000000;">
in the front of the output. Probably the "black font" tag shouldn't be opened in the first place, but it wouldn't be much of a problem if it was closed properly with another </span>
at the end (I'm passing output of ansifilter further to notify-send
which doesn't recognize it as valid HTML and treats it as plain text).