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

Added a safeguard for invalid uploads causing fatals in API endpoints. #40726

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
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
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Jetpack API: Fixed a bug where invalid upload input caused a fatal error.
5 changes: 5 additions & 0 deletions projects/plugins/jetpack/class.json-api-endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -2254,6 +2254,11 @@ public function handle_media_creation_v1_1( $media_files, $media_urls, $media_at

if ( ! $user_can_upload_files ) {
$media_id = new WP_Error( 'unauthorized', 'User cannot upload media.', 403 );
} elseif ( ! is_array( $media_item ) ) {
$media_id = new WP_Error( 'invalid_input', 'Unable to process request.', 400 );
$media_item = array(
'name' => 'invalid_file',
);
} elseif ( $this->media_item_is_free_video_mobile_upload_and_too_long( $media_item ) ) {
$media_id = new WP_Error( 'upload_video_length', 'Video uploads longer than 5 minutes require a paid plan.', 400 );
} else {
Expand Down
Loading