Masterminds / Masterminds/html5-php
Invalid parsing result when head/body tag is missing
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 1.8k
- Forks
- 122
- PR merge metrics
- No merged PRs in 30d
Description
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: https://github.com/roundcube/roundcubemail/issues/6713#issuecomment-480320339
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two examples through loadHTML() and compare the HTML5 parser result with DOMDocument. Read the parser path handling omitted html and body start tags, using the linked Mozilla rules as the expected behavior. Done means text before and after the br element is preserved in both examples, with regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100