Skip to content
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

Fix allowed HTML tags declaration in wp_trigger_error() #6671

Closed

Conversation

thelovekesh
Copy link
Member

@thelovekesh thelovekesh commented May 29, 2024

Update allowed HTML tags declaration in wp_trigger_error().

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

Commit Message

General: Fix array format for allowed HTML passed into wp_kses() for wp_trigger_error().

Kses requires an associative array of allowed HTML.

See #57686. Follow-up to [56707].

Props thelovekesh, westonruter.
Fixes #61318.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copy link

github-actions bot commented May 29, 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 thelovekesh, westonruter.

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

@thelovekesh
Copy link
Member Author

Hey @hellofromtonya 👋🏼

Can you please review this PR? Thanks.

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.

'code',
'em',
'strong',
'a' => array( 'href' ),
Copy link
Member

Choose a reason for hiding this comment

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

Is this right? I believe it should rather be:

Suggested change
'a' => array( 'href' ),
'a' => array( 'href' => true ),
Copy link
Member Author

Choose a reason for hiding this comment

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

This is required. Error strings having <a href="/"></a> are being stripped out without your suggestion.

Copy link
Member

Choose a reason for hiding this comment

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

Humm, in core it shows it is supposed to be 'href' => true:

$allowedposttags = array(
'address' => array(),
'a' => array(
'href' => true,

Copy link
Member

Choose a reason for hiding this comment

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

Oh, you applied this suggestion in the end anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

First I added a test case afbacc0 which turned out to be failing, so added the suggested fix 7b0029c.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I misread what you wrote. I thought you said with my suggestion not without 😊

'function_name' => 'some_function',
'message' => '<script>alert("expected the function name and message")</script>',
'expected_message' => 'some_function(): alert("expected the function name and message")',
),
Copy link
Member

Choose a reason for hiding this comment

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

Please add a test case with a link in it to check whether it survives the Kses sanitization mentioned in https://github.com/WordPress/wordpress-develop/pull/6671/files#r1628482559. Like try adding a test with a link to see if it fails then apply the above suggestion if it does.

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

Looks good!

@westonruter
Copy link
Member

Committed in r58361 (da1ad31).

@westonruter westonruter closed this Jun 7, 2024
@thelovekesh thelovekesh deleted the fix/wp-trigger-error-kses branch June 7, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants