mojo icon indicating copy to clipboard operation
mojo copied to clipboard

Mojo::DOM treats "-- >" as end of comment (it shouldn't)

Open mauke opened this issue 2 years ago • 1 comments

  • 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.

mauke avatar Jan 29 '23 20:01 mauke

So it should no longer support HTML style comment?

<!-- HTML4 -- >
<!-- HTML5 -->

poti1 avatar Jun 24 '23 17:06 poti1