wordpress-activitypub
wordpress-activitypub copied to clipboard
Strip whitespace between HTML tags instead of all content
Fixes #2592 Supersedes #2595
Proposed changes:
- Add
Sanitize::strip_whitespace()method that only removes newlines, carriage returns, and tabs between HTML tags (/>[\n\r\t]+</) rather than stripping them from all content. - This preserves whitespace inside preformatted elements like
<pre>and<code>blocks without needing special handling. - Update
Shortcodes::content()to use the new sanitization method. - Remove redundant
wpautop()and whitespace stripping fromPost::get_content()since content is already processed.
Other information:
- [x] Have you written new tests for your changes, if applicable?
Testing instructions:
- Create a post with a code block containing multiple lines
- Publish the post
- View the federated content on a remote instance (or inspect the ActivityPub JSON at
/wp-json/activitypub/1.0/posts/{id}) - Verify the code block preserves newlines and formatting
Changelog entry
- [x] Automatically create a changelog entry from the details below.
Changelog Entry Details
Significance
- [x] Patch
- [ ] Minor
- [ ] Major
Type
- [ ] Added - for new features
- [ ] Changed - for changes in existing functionality
- [ ] Deprecated - for soon-to-be removed features
- [ ] Removed - for now removed features
- [x] Fixed - for any bug fixes
- [ ] Security - in case of vulnerabilities
Message
Preserve whitespace inside preformatted elements when federating content.
Is this ready for review?
@obenland Seems to work like expected