Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser remove the single < (less than) character #249

Closed
touhidurabir opened this issue Jul 5, 2024 · 1 comment
Closed

Parser remove the single < (less than) character #249

touhidurabir opened this issue Jul 5, 2024 · 1 comment

Comments

@touhidurabir
Copy link

touhidurabir commented Jul 5, 2024

The HTML parser removes the single use of < character form the given string . 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 printing of $html5->saveHTML($dom) should return

<!DOCTYPE html>
<html><img src="invalid-url" onerror="alert('XSS Attack prefix')"> 2 &gt; 1 &amp; 3  &lt; 5 and some more text</html>

but instead it returns

<!DOCTYPE html>
<html><img src="invalid-url" onerror="alert('XSS Attack prefix')"> 2 &gt; 1 &amp; 3  5 and some more text</html>

See the missing encoded &lt; of < character .

@touhidurabir
Copy link
Author

Sorry for duplicate post as for some reason at the first submission, github showed Something went wrong and thought it did not saved . It can be removed/closed in prefer to #250

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant