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

Image caption shortcode parameter validation #5375

Conversation

BrianHenryIE
Copy link

Refresh of #4939

In versions of PHP 7.0 and prior, if anything other than an array was passed into this function, it would be cast to an array at $attr['caption'] = trim( $matches[2] );

To maintain that behavior in newer versions of PHP, I added a type check that would explicitly perform this behavior.

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

Matt Pierce and others added 3 commits July 31, 2023 09:42
This was confirmed failing without the previous commit – validates that the patch works
@@ -2349,6 +2349,14 @@ function _wp_post_thumbnail_context_filter_remove() {
* @return string HTML content to display the caption.
*/
function img_caption_shortcode( $attr, $content = '' ) {
/**
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/**
/*

Remove extra star from comment

Copy link
Author

Choose a reason for hiding this comment

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

That is not suggested by WPCS.

A regex search of the WordPress core codebase for \/\*[^\*]*]\s*$ does not find any example of the suggestion already in use.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Fixed now.

@swissspidy
Copy link
Member

Such a check was once added in https://core.trac.wordpress.org/changeset/56488

@swissspidy swissspidy closed this Feb 2, 2024
Copy link

github-actions bot commented Feb 2, 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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @piercema@montclair.edu.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

Core SVN

If you're a Core Committer, use this list when committing to wordpress-develop in SVN:

Props: brianhenryie, mukesh27, swissspidy.

GitHub Merge commits

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: piercema@montclair.edu.

Co-authored-by: BrianHenryIE <brianhenryie@git.wordpress.org>
Co-authored-by: mukeshpanchal27 <mukesh27@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants