Skip to content

Guard against empty body in DOMDocument::loadHTML()#596

Merged
pfefferle merged 1 commit intomainfrom
fix/332-empty-post-content
Mar 30, 2026
Merged

Guard against empty body in DOMDocument::loadHTML()#596
pfefferle merged 1 commit intomainfrom
fix/332-empty-post-content

Conversation

@pfefferle
Copy link
Copy Markdown
Owner

Summary

  • Adds an empty() check after mb_convert_encoding() in Response::get_dom_document() to prevent a ValueError when DOMDocument::loadHTML() receives an empty string on PHP 8.1+.
  • The existing ! $body check guards against empty input, but mb_convert_encoding() can return an empty string in edge cases (e.g., encoding detection failure), bypassing that guard.

Fixes #332

Test plan

  • Verify that a post with empty post_content does not trigger a ValueError from DOMDocument::loadHTML()
  • Verify that normal webmention sending still works for posts with content

Add an additional empty check after mb_convert_encoding() to prevent
a ValueError when loadHTML() receives an empty string in PHP 8.1+.

Fixes #332
@pfefferle pfefferle merged commit aa225b8 into main Mar 30, 2026
9 checks passed
@pfefferle pfefferle deleted the fix/332-empty-post-content branch March 30, 2026 18:01
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

Successfully merging this pull request may close these issues.

Better support for empty post_content

1 participant