Making WordPress.org

Changeset 15148


Ignore:
Timestamp:
09/04/2026 07:57:23 PM (2 weeks ago)
Author:
obenland
Message:

Photo Directory: refuse submitted shortcodes instead of editing them out

Closes https://github.com/WordPress/wordpress.org/pull/875.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/uploads.php

    r15146 r15148  
    430430                                        $rejection = __( 'Your submission must be an image in the JPEG format.', 'wporg-photos' );
    431431                                        break;
     432                                case 'shortcode-in-text':
     433                                        $rejection = __( 'The title, description, and caption cannot contain shortcodes. Please remove them and submit again.', 'wporg-photos' );
     434                                        break;
    432435                                case 'file-too-large':
    433436                                        $rejection = sprintf(
     
    499502                        }
    500503
    501                         $value = $sanitize( wp_unslash( $post_array[ $field ] ) );
    502 
    503                         $post_array[ $field ] = wp_slash( strip_shortcodes( $value ) );
     504                        $post_array[ $field ] = wp_slash( $sanitize( wp_unslash( $post_array[ $field ] ) ) );
    504505                }
    505506
     
    701702                if ( ! isset( $_POST['photo_license'] ) || ! $_POST['photo_license'] ) {
    702703                        return 'checkbox_unchecked_license';
     704                }
     705
     706                foreach ( [ 'post_title', 'post_content', 'post_excerpt' ] as $field ) {
     707                        // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Read raw: sanitizing before the check would hide what it looks for.
     708                        $submitted = isset( $_POST[ $field ] ) ? wp_unslash( $_POST[ $field ] ) : '';
     709
     710                        // A field can arrive as an array, which Frontend Uploader drops before it builds the post.
     711                        if ( ! is_string( $submitted ) || '' === $submitted ) {
     712                                continue;
     713                        }
     714
     715                        if ( preg_match( '/' . get_shortcode_regex() . '/', $submitted ) ) {
     716                                return 'shortcode-in-text';
     717                        }
    703718                }
    704719
Note: See TracChangeset for help on using the changeset viewer.