Repository navigation
Reader: show the body of a reposted comment instead of an empty quote - #51903
Conversation
core/quote stopped rendering its `value` attribute in WordPress 6.1. All that survives of it is a load-time migration that reads the value with a `p` selector, so a body that is not already inside a top-level `<p>` is dropped outright. The repost flow's text quote wrapped its content and so kept working; the comment quote passed `comment_content` straight through, and a comment that was plain text, or inline markup with no paragraph of its own, came out as an empty blockquote with the author still attached. Build the body as `core/paragraph` inner blocks instead. Runs of loose content are wrapped rather than discarded, so a body that mixes the two keeps all of itself, and a quote with nothing left to show is skipped rather than credited to someone.
…t-quote # Conflicts: # projects/plugins/jetpack/extensions/shared/reader-repost.js # projects/plugins/jetpack/extensions/shared/test/reader-repost.test.js
The merge resolution went in with hooks skipped, so ESLint never saw the two helpers the merged test file added.
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 1 file.
|
Fixes #
Proposed changes
core/paragraphinner blocks instead of the deprecatedvalueattribute, so it actually renders.core/quotestopped renderingvaluein WordPress 6.1 (Gutenberg 13.8, WordPress/gutenberg#25892). All that survives of the attribute is a load-time migration,migrateToQuoteV2(), which reads it with apselector — so anything that is not already inside a top-level<p>is dropped on sight.The repost flow's text quote wrapped its content in
<p>and so kept working. The comment quote passedcomment_contentstraight through, and a comment that was plain text, or inline markup with no paragraph of its own, came out as an empty blockquote with the author still attached:This is not a regression with a window.
reader-repost.jslanded in March 2025, two and a half years after WordPress 6.1, so the feature has been broken since the day it shipped — and Jetpack requires WordPress 7.0, so no supported version rendersvalue. The attribute is also explicitly on the way out: the block logsdeprecated( 'Value attribute on the quote block', { since: '6.0', version: '6.5' } ).Three details worth a reviewer's attention:
<blockquote>is flattened into a paragraph. It is the one tag the comment allowlist keeps that cannot live inside a<p>; wrapping it would serialize to<p><blockquote>, which the parser closes early on the way back in, stranding the text outside the block it belongs to. Flattening keeps the words and loses only the indentation.Sanitization behavior is unchanged.
createQuoteBody()runs on the output of the existingsanitizeCommentContent(), so the ordering is sanitize first, then split into paragraphs.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
You need a site where the block editor loads Jetpack's editor extensions (connected, or offline mode with the Blocks module active).
Open this URL on that site, substituting your own host:
Before this change, the second quote renders as an empty blockquote attributed to
AUTH1—PLAINTEXTONLYappears nowhere in the editor or in the saved post. After, it renders asPLAINTEXTONLYwith theAUTH1citation.Confirm the body survives a save: save the draft, reload the editor, and check the quote still has its paragraph. Reading
post_contentdirectly (wp post get <id> --field=post_content) is a good extra check.Vary
comment_contentto cover the shapes the Reader can send. Each should render its text, and the last should produce no quote block at all:comment_contentPLAINTEXTONLYPLAINTEXTONLY<a href="https://example.com/x">LINKONLY</a><p>FIRST</p><p>SECOND</p><p>LINE1<br>LINE2</p>loose <em>text</em><p>PARA</p><blockquote cite="https://example.com">bq text</blockquote>bq textSanitization should behave exactly as it does on trunk. These should still be neutralized, now inside the paragraph rather than the
valueattribute:comment_content<p>before</p><iframe srcdoc="<script>alert(1)</script>">x</iframe><p>after</p>before/x/after; noiframe, nosrcdoc<p><a href="javascript:alert(1)">click</a></p><a>click</a>— href dropped<p>before</p><!-- /wp:quote --><!-- wp:html --><p>after</p><script>alert(1)</script>Unit tests:
jetpack test js plugins/jetpack, orpnpm run test-extensions reader-repostfromprojects/plugins/jetpack.