Skip to content

Preserve target="_blank" in Biographical Info and Category Description#7792

Closed
Sukhendu2002 wants to merge 4 commits intoWordPress:trunkfrom
Sukhendu2002:fix/user-profile-bio-link-target-stripping
Closed

Preserve target="_blank" in Biographical Info and Category Description#7792
Sukhendu2002 wants to merge 4 commits intoWordPress:trunkfrom
Sukhendu2002:fix/user-profile-bio-link-target-stripping

Conversation

@Sukhendu2002
Copy link

Preserve target="_blank" in Biographical Info and Category Description

Description

This pull request ensures that the target="_blank" attribute is preserved when adding links in the Biographical Info and Category Description fields. Previously, this attribute was being stripped by the kses sanitization process.

Additionally, new unit tests have been added to verify the preservation of the target="_blank" attribute in these specific contexts.

Changes Made

  • Added the target attribute to the allowed tags in the user_description and pre_term_description contexts in wp_kses_allowed_html().
  • Added the following new unit tests:
    • test_target_attribute_preserved_in_user_description()
    • test_target_attribute_preserved_in_term_description()
    • test_target_attribute_preserved_in_user_description_with_other_attributes()
    • test_target_attribute_preserved_in_term_description_with_other_attributes()

Trac ticket: https://core.trac.wordpress.org/ticket/12056

@github-actions
Copy link

github-actions bot commented Nov 13, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props sukhendu2002, audrasjb, martinkrcho, guillaumeturpin.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@gturpin-dev
Copy link

I just checked the implementation and tests

LGTM 🎉

Copy link

@martinkrcho martinkrcho left a comment

Choose a reason for hiding this comment

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

It would be great to use data providers for the new tests.
https://phpunit.de/manual/3.7/en/appendixes.annotations.html#appendixes.annotations.dataProvider

The new test methods do very similar thing in each of them.

@Sukhendu2002
Copy link
Author

@martinkrcho, Thanks for the suggestion! I’ve updated the tests to use data providers accordingly.

@audrasjb
Copy link
Contributor

committed in https://core.trac.wordpress.org/changeset/59677

@audrasjb audrasjb closed this Jan 21, 2025
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.

4 participants