fix: use wp_kses_post() instead of esc_url() for HTML output in distributor_the_original_site_link()#1379
Conversation
Replace esc_url() with wp_kses_post() in distributor_the_original_site_link(). distributor_get_original_site_link() returns a complete <a> tag with esc_url() and esc_html() already applied internally. Wrapping HTML in esc_url() encodes angle brackets and breaks the rendered link. Fixes 10up#1378
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the output escaping for the “original site link” template tag so HTML returned by the getter is safely rendered instead of being incorrectly treated as a URL.
Changes:
- Replace
esc_url()withwp_kses_post()when echoing the original site link markup.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@thisismyurl thank you for the pull request. I've taken the liberty of reformatting your PR description using the repository template. Are you able to review the test details I've provided to ensure you are happy with them. We also require contributors to review and agree to the repos code of conduct, are you able to read through them and check the checkbox "I agree to follow this project's Code of Conduct." in the PR's description if you are happy with them. Once I hear back, I'll approve and merge the pull request. |
|
Hi @peterwilsoncc — I've read through the Code of Conduct and checked the box. Your test steps look right to me: the bug shows up any time Thanks for reformatting the description and for the detailed test case. |
peterwilsoncc
left a comment
There was a problem hiding this comment.
LGTM and tests well, thank you!
Description of the Change
Summary
distributor_the_original_site_link()wraps the return value ofdistributor_get_original_site_link()inesc_url()before echoing it.distributor_get_original_site_link()returns a fully-formed<a href="...">...</a>anchor tag — not a bare URL — withesc_url()andesc_html()already applied internally.Wrapping HTML in
esc_url()encodes angle brackets, quotes, and ampersands. The rendered output is escaped text rather than a clickable link.This PR replaces
esc_url()withwp_kses_post(), which permits the safe HTML subset the getter already produces.Before:
After:
Fixes #1378
Developed and tested with AI assistance (Claude + internal review pipeline). Changes were verified against the function's return value before implementation.
How to test the Change
wp eval --url=[destination site] "distributor_the_original_site_link([post id]);"replacing the placeholders as appropriateChangelog Entry
Credits
Props @thisismyurl
Checklist: