Skip to content

Use PHP 8.4+ \Dom classes and functions - #9567

Merged
Alkarex merged 23 commits into
FreshRSS:edgefrom
Alkarex:php84-dom
Nov 19, 2026
Merged

Alkarex merged 23 commits into
FreshRSS:edgefrom
Alkarex:php84-dom

Conversation

@Alkarex

@Alkarex Alkarex commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

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

SimplePie: Use PHP 8.4+ \Dom classes and functions

SimplePie: Add unit test for HTML5 sanitizing compliance

SimplePie: Remove obsolete xml_is_sane and XMLReader fallback

CssXPath: Add support for case insensitivity

fix #5201
fix #6830
fix #6831

~5% faster for HTML sanitising.
Remove SimpleXML. Remove XMLReader.

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

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

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

fix FreshRSS#5201
fix FreshRSS#6830
fix FreshRSS#6831
@Alkarex

Alkarex commented Nov 15, 2026

Copy link
Copy Markdown
Member Author

Replaces #9050

Comment thread .github/workflows/tests.yml Fixed
@Inverle

Inverle commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

#9567 (comment)

Maybe try with 2.40.0 instead of v2.40.0?

That's what the tag is called: https://github.com/shivammathur/setup-php/releases/tag/2.40.0

@Alkarex

Alkarex commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

Maybe try with 2.40.0 instead of v2.40.0?

Nice catch: I thought it was due to the test running before I gave permissions for the action in the repo settings

Alkarex added a commit that referenced this pull request Nov 17, 2026
Convinience command to test all supported versions of PHP at once
Used for #9567
@Alkarex Alkarex added Bug (confirmed) 🐞 issues that are reproducible Important 🔥 labels Nov 17, 2026
@Alkarex

Alkarex commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

@Inverle Inverle added UI 🎨 User Interfaces and removed UI 🎨 User Interfaces 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
Alkarex merged commit ea646d2 into FreshRSS:edge Nov 19, 2026
4 checks passed
@Alkarex
Alkarex deleted the php84-dom branch November 19, 2026 22:17
@Alkarex

Alkarex commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

@Alkarex Alkarex mentioned this pull request Nov 23, 2026
Alkarex added a commit that referenced this pull request Nov 24, 2026
Upstream PR is merged:
* phpgt/CssXPath#256

Follow-up of #9567
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

3 participants