Skip to content

Add unit test for HTML5 sanitizing compliance - #1022

Open
Alkarex wants to merge 3 commits into
simplepie:masterfrom
FreshRSS:testSanitizeHtml5TagClosingCompliance
Open

Alkarex wants to merge 3 commits into
simplepie:masterfrom
FreshRSS:testSanitizeHtml5TagClosingCompliance

Conversation

@Alkarex

@Alkarex Alkarex commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Add unit test for #1021 (skipped for PHP < 8.4)
Failing to sanitise HTML according to current HTML standard breaks the case of trusting SimplePie sanitising to include items from an RSS feed into an HTML page to be rendered in a Web browser.

--- Expected
+++ Actual
@@ @@
 '<ul>
-    <li><div></div></li>
+    <li><div>
     <li>Item</li>
-</ul>'
+</div></li></ul>'

Add unit test for simplepie#1021
Failing to sanitize HTML according to current HTML standard break the case of trusting SimplePie sanitizing to show items from an RSS feed into an HTML page to be show in a Web browser.
@pull-request-size pull-request-size Bot added size/S and removed size/M labels Nov 18, 2026
Alkarex added a commit to FreshRSS/simplepie that referenced this pull request Nov 19, 2026
https://wiki.php.net/rfc/domdocument_html5_parser
https://wiki.php.net/rfc/opt_in_dom_spec_compliance

Polyfill `Dom\` classes for PHP < 8.4.

Needs PHPStan 2+: #97

Needed for fixing issues such as FreshRSS/FreshRSS#5201

Currently, SimplePie uses legacy DOMDocument parsing, which outputs potentially problematic HTML, not correctly sanitised.
This breaks the assumption that one can use something like `<div><!-- some HTML sanitized from SimplePie --></div>`.

```
--- Expected
+++ Actual
@@ @@
 '<ul>
-    <li><div></div></li>
+    <li><div>
     <li>Item</li>
-</ul>'
+</div></li></ul>'
```

When shown in a compliant Web browser, several tags will be wrongly closed, breaking the layout of the client.

This PR patches SimplePie to use the modern parser and code syntax, while maintaining a best-effort polyfill for legacy PHP versions < 8.4.

Downstream:
* FreshRSS/FreshRSS#9567

Upstream:
* simplepie#1021
* simplepie#1022
* simplepie#1023
Alkarex added a commit to FreshRSS/FreshRSS that referenced this pull request Nov 19, 2026
Currently, SimplePie uses legacy DOMDocument parsing, which outputs potentially problematic HTML, not correctly sanitised.
This breaks the assumption that one can use something like `<div><!-- some HTML sanitized from SimplePie --></div>`.

```
--- Expected
+++ Actual
@@ @@
 '<ul>
-    <li><div></div></li>
+    <li><div>
     <li>Item</li>
-</ul>'
+</div></li></ul>'
```

When shown in a compliant Web browser, several tags will be wrongly closed, breaking the layout of the client.

This PR patches SimplePie to use the modern parser and code syntax, while maintaining a best-effort polyfill for legacy PHP versions < 8.4.

Depends on:

SimplePie: Upgrade to PHPStan 2
* FreshRSS/simplepie#97
* simplepie/simplepie#939
* simplepie/simplepie#1019

SimplePie: Use PHP 8.4+ \Dom classes and functions
* FreshRSS/simplepie#98
* simplepie/simplepie#1021

SimplePie: Add unit test for HTML5 sanitizing compliance
* simplepie/simplepie#1022

SimplePie: Remove obsolete xml_is_sane and XMLReader fallback
* simplepie/simplepie#1023

CssXPath: Add support for case insensitivity
* phpgt/CssXPath#256

fix #5201
fix #6830
fix #6831

~5% faster for HTML sanitising.
Remove SimpleXML. Remove XMLReader.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant