diff --git a/admin/class-rtgodam-transcoder-admin.php b/admin/class-rtgodam-transcoder-admin.php index 31befc628a..e9b3e13abc 100644 --- a/admin/class-rtgodam-transcoder-admin.php +++ b/admin/class-rtgodam-transcoder-admin.php @@ -379,6 +379,10 @@ public function free_plan_admin_notice() { public function dismiss_free_plan_notice() { check_ajax_referer( 'dismiss_free_plan_notice', 'nonce' ); + if ( ! current_user_can( 'manage_options' ) ) { + wp_send_json_error( array( 'message' => __( 'Insufficient permissions.', 'godam' ) ), 403 ); + } + // Store timestamp for 7-day temporary dismissal. update_option( 'rtgodam_free_plan_notice_dismissed_timestamp', time() ); @@ -393,6 +397,10 @@ public function dismiss_free_plan_notice() { public function dismiss_woo_promo_notice() { check_ajax_referer( 'dismiss_woo_promo_notice', 'nonce' ); + if ( ! current_user_can( 'manage_options' ) ) { + wp_send_json_error( array( 'message' => __( 'Insufficient permissions.', 'godam' ) ), 403 ); + } + // Store timestamp for 30-day temporary dismissal. update_option( 'rtgodam_woo_promo_dismissed_timestamp', time() ); diff --git a/inc/classes/class-media-library-ajax.php b/inc/classes/class-media-library-ajax.php index fa01d83059..76a6c08656 100644 --- a/inc/classes/class-media-library-ajax.php +++ b/inc/classes/class-media-library-ajax.php @@ -1093,6 +1093,10 @@ private function sanitize_date_query( $date_query ) { public function dismiss_offer_banner() { check_ajax_referer( 'godam-dismiss-offer-banner-nonce', 'nonce' ); + if ( ! current_user_can( 'manage_options' ) ) { + wp_send_json_error( array( 'message' => __( 'Insufficient permissions.', 'godam' ) ), 403 ); + } + if ( get_option( 'rtgodam-offer-banner' ) === false ) { add_option( 'rtgodam-offer-banner', 0 ); } else { diff --git a/inc/classes/sureforms/class-form-submit.php b/inc/classes/sureforms/class-form-submit.php index 21399817a4..d2117d50dd 100644 --- a/inc/classes/sureforms/class-form-submit.php +++ b/inc/classes/sureforms/class-form-submit.php @@ -106,7 +106,7 @@ public function prepare_submission_data( $submission_data ) { // Loop through each file and check for `recorder` field data. foreach ( $_FILES as $input_key => $file_data ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing - if ( false === strpos( $input_key, '-input-recorder' ) ) { + if ( ! self::is_recorder_file_key( $input_key ) ) { continue; } @@ -151,8 +151,22 @@ public function prepare_submission_data( $submission_data ) { 'size' => $file_size, ); + // Only audio and video, checked against the file itself rather than the type the browser sent. + $recorder_mimes = self::get_recorder_upload_mimes(); + + // An empty list would let WordPress fall back to every allowed type, so refuse instead. + if ( empty( $recorder_mimes ) ) { + wp_send_json_error( + array( + 'message' => __( 'File is not uploaded', 'godam' ), + ) + ); + } + $upload_overrides = array( 'test_form' => false, + 'test_type' => true, + 'mimes' => $recorder_mimes, ); $move_file = wp_handle_upload( $uploaded_file, $upload_overrides ); @@ -175,6 +189,41 @@ public function prepare_submission_data( $submission_data ) { return $submission_data; } + /** + * Whether a posted file key is a GoDAM recorder field's. + * + * The recorder block names its input `godam-upload--lbl-