Mojo::DOM treats "-- >" as end of comment (it shouldn't)
mauke opened this issue · comments
mauke commented
- Mojolicious version: 9.31
- Perl version: v5.36.0
- Operating system: Ubuntu 22.04.1 LTS
Steps to reproduce the behavior
#!/usr/bin/env perl
use v5.12.0;
use warnings;
use Test::More;
use Mojo::DOM;
my $dom = Mojo::DOM->new('<!-- a > -- > b <blink>c</blink> -->');
is_deeply
$dom->find('blink')->map(sub { $_->to_string })->to_array,
[],
'no blink element found in comment';
done_testing;
Expected behavior
Test passes.
After seeing two dashes in a comment, we are in the comment end state. The only semantically interesting characters at this point are >
, !
, -
, and EOF. Anything else (including spaces) adds the --
to the comment string and switches back to the normal comment state. The comment only ends with -->
at end of input.
Actual behavior
not ok 1 - no blink element found in comment
# Failed test 'no blink element found in comment'
# at mojo-dom-bug-7.pl line 10.
# Structures begin differing at:
# $got->[0] = '<blink>c</blink>'
# $expected->[0] = Does not exist
1..1
# Looks like you failed 1 test of 1.
poti1 commented
So it should no longer support HTML style comment?
<!-- HTML4 -- >
<!-- HTML5 -->