Skip to content

Re-add HTML handling for summaries/excerpts #1731

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

Merged
merged 5 commits into from
May 27, 2025
Merged

Conversation

pfefferle
Copy link
Member

We removed the HTML handling for excerpts and summaries because Mastodon has not supported it. Now that Mastodon has merged this PR mastodon/mastodon#28629 I think it is fine to re-add the HTML handling.

Proposed changes:

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Go to '..'

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • 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
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Re-enabled HTML support in excerpts and summaries to properly display hashtags and @-replies, now that Mastodon supports it.

@pfefferle pfefferle requested review from obenland and Copilot May 27, 2025 09:21
@pfefferle pfefferle self-assigned this May 27, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Re-enable HTML handling for excerpts and summaries now that Mastodon supports it.

  • Restores the use of apply_filters('the_excerpt') in generate_post_summary to include HTML formatting.
  • Applies HTML processing to all activity summary types in filter_activity_object.
  • Cleans up obsolete comment blocks in both files.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
includes/functions.php Removed commented-out code and replaced it with a direct call to \apply_filters('the_excerpt') along with an updated inline comment.
includes/class-link.php Dropped the restricted type check and now processes HTML for all non-empty summaries.
Comments suppressed due to low confidence (2)

includes/functions.php:1226

  • Consider sanitizing the output of apply_filters('the_excerpt', $content) using wp_kses_post() or a similar function to ensure only safe HTML is rendered and prevent potential XSS vulnerabilities.
return \apply_filters( 'the_excerpt', $content );

includes/functions.php:1226

  • Add a unit or integration test to verify that HTML in excerpts is correctly passed through and that any sanitization behaves as expected.
return \apply_filters( 'the_excerpt', $content );

Copy link
Member

@obenland obenland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@pfefferle pfefferle merged commit 170bab3 into trunk May 27, 2025
11 checks passed
@pfefferle pfefferle deleted the update/summary-handling branch May 27, 2025 13:11
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.

3 participants