Skip to content

Invalid parsing result when head/body tag is missing #166

Open
@alecpl

Description

@alecpl

Consider this:

<html>Hello, This is a test.<br />Does it work this time?</html>

Imo, this is valid HTML and it is also parsed correctly by DOMDocument. However, HTML5 parser will ignore the first line of text. We're using loadHTML() method.

Even this one works with DOMDocument:

Hello, This is a test.<br />Does it work this time?

According to Mozilla documentation:

  • html: The start tag may be omitted if the first thing inside the element is not a comment.
  • body: The start tag may be omitted if the first thing inside it is not a space character, comment, <script> element or <style> element.

Reference: roundcube/roundcubemail#6713 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions