Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,9 @@ public static function customize_fu_response_notices( $notices ) {
case 'file-not-jpg':
$rejection = __( 'Your submission must be an image in the JPEG format.', 'wporg-photos' );
break;
case 'shortcode-in-text':
$rejection = __( 'The title, description, and caption cannot contain shortcodes. Please remove them and submit again.', 'wporg-photos' );
break;
case 'file-too-large':
$rejection = sprintf(
__( 'The file size for your submission is too large. Please submit a photo smaller than %d MB in size.', 'wporg-photos' ),
Expand Down Expand Up @@ -498,9 +501,7 @@ public static function sanitize_submitted_description( $post_array ) {
continue;
}

$value = $sanitize( wp_unslash( $post_array[ $field ] ) );

$post_array[ $field ] = wp_slash( strip_shortcodes( $value ) );
$post_array[ $field ] = wp_slash( $sanitize( wp_unslash( $post_array[ $field ] ) ) );
}

return $post_array;
Expand Down Expand Up @@ -702,6 +703,20 @@ protected static function validate_upload_form() {
return 'checkbox_unchecked_license';
}

foreach ( [ 'post_title', 'post_content', 'post_excerpt' ] as $field ) {
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Read raw: sanitizing before the check would hide what it looks for.
$submitted = isset( $_POST[ $field ] ) ? wp_unslash( $_POST[ $field ] ) : '';

// A field can arrive as an array, which Frontend Uploader drops before it builds the post.
if ( ! is_string( $submitted ) || '' === $submitted ) {
continue;
}

if ( preg_match( '/' . get_shortcode_regex() . '/', $submitted ) ) {
return 'shortcode-in-text';
}
}

return false;
}

Expand Down