Masterminds / Masterminds/html5-php
Parser remove the single < (less than) character from given html string
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 1.8k
- Forks
- 122
- PR merge metrics
- No merged PRs in 30d
Description
When parsing a html string with single use of <, it removes it from the parsed value that being returned . For example
<?php
use Masterminds\HTML5;
$html = '<img src="invalid-url" onerror="alert(\'XSS Attack prefix\')" /> 2 > 1 & 3 < 5 and some more text';
// Parse the document. $dom is a DOMDocument.
$html5 = new HTML5();
$dom = $html5->loadHTML($html);
// Render it as HTML5:
print $html5->saveHTML($dom);
the print of $html5->saveHTML($dom) should return as
<!DOCTYPE html>
<html><img src="invalid-url" onerror="alert('XSS Attack prefix')"> 2 > 1 & 3 < 5 and some more text</html>
but instead it return as
<!DOCTYPE html>
<html><img src="invalid-url" onerror="alert('XSS Attack prefix')"> 2 > 1 & 3 5 and some more text</html>
see the missing encoded < of < character .
This is a continuation of https://github.com/symfony/symfony/issues/57597 where it is impacting the sanitization process of html-sanitizer
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 with the PHP reproduction in the issue and trace the loadHTML/saveHTML parsing and serialization path for a standalone less-than character. Confirm the output against the expected HTML, with the character preserved as < rather than removed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100