Skip to content
Open
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
22 changes: 22 additions & 0 deletions includes/admin/feedzy-rss-feeds-import.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
/**
* The admin-specific functionality of the plugin.
Expand Down Expand Up @@ -756,7 +756,7 @@
// Added this to activate post if publish is clicked and sometimes it does not change status.
if (
$source_is_valid && isset( $_POST['custom_post_status'] ) &&
'Publish' === sanitize_text_field( $_POST['custom_post_status'] )

Check warning on line 759 in includes/admin/feedzy-rss-feeds-import.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.Security.ValidatedSanitizedInput.MissingUnslash

$_POST['custom_post_status'] not unslashed before sanitization. Use wp_unslash() or similar
) {
$activate = array(
'ID' => $post_id,
Expand Down Expand Up @@ -1365,7 +1365,7 @@
private function get_taxonomies() {
check_ajax_referer( FEEDZY_BASEFILE, 'security' );

$post_type = isset( $_POST['post_type'] ) ? sanitize_text_field( $_POST['post_type'] ) : '';

Check warning on line 1368 in includes/admin/feedzy-rss-feeds-import.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.Security.ValidatedSanitizedInput.MissingUnslash

$_POST['post_type'] not unslashed before sanitization. Use wp_unslash() or similar
$taxonomies = get_object_taxonomies(
array(
'post_type' => $post_type,
Expand Down Expand Up @@ -1436,7 +1436,7 @@
private function dry_run() {
check_ajax_referer( FEEDZY_BASEFILE, 'security' );

$fields = urldecode( isset( $_POST['fields'] ) ? sanitize_url( $_POST['fields'] ) : '' );

Check warning on line 1439 in includes/admin/feedzy-rss-feeds-import.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.Security.ValidatedSanitizedInput.MissingUnslash

$_POST['fields'] not unslashed before sanitization. Use wp_unslash() or similar
parse_str( $fields, $data );

$feedzy_meta_data = $data['feedzy_meta_data'];
Expand Down Expand Up @@ -1596,7 +1596,7 @@
do_action( 'feedzy_run_cron_extra', $job );
} catch ( Exception $e ) {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log( '[Feedzy Run Cron][Post title: ' . ( ! empty( $job->post_title ) ? $job->post_title : '' ) . '] Error: ' . $e->getMessage() );

Check warning on line 1599 in includes/admin/feedzy-rss-feeds-import.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.PHP.DevelopmentFunctions.error_log_error_log

error_log() found. Debug code should not normally be used in production.
}

Feedzy_Rss_Feeds_Log::error(
Expand Down Expand Up @@ -1791,7 +1791,7 @@
delete_post_meta( $job->ID, 'import_info' );

// let's increase this time in case spinnerchief/wordai is being used.
set_time_limit( apply_filters( 'feedzy_max_execution_time', 500 ) );

Check warning on line 1794 in includes/admin/feedzy-rss-feeds-import.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

Squiz.PHP.DiscouragedFunctions.Discouraged

The use of function set_time_limit() is discouraged

$count = 0;
$index = 0;
Expand Down Expand Up @@ -3036,6 +3036,11 @@
$type = $this->get_file_type_by_url( $img_source_url );
}

// Normalize the MIME type: lowercase and strip any parameters (e.g., "; charset=UTF-8").
if ( ! empty( $type ) ) {
$type = strtolower( trim( explode( ';', $type )[0] ) );
}

// the file is downloaded with a .tmp extension
// if the URL mentions the extension of the file, the upload succeeds
// but if the URL is like https://source.unsplash.com/random, then the upload fails
Expand All @@ -3044,7 +3049,7 @@
$new_local_file = str_replace( '.tmp', str_replace( 'image/', '.', $type ), $local_file );

// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_rename
$renamed = rename( $local_file, $new_local_file );

Check failure on line 3052 in includes/admin/feedzy-rss-feeds-import.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.WP.AlternativeFunctions.rename_rename

rename() is discouraged. Use WP_Filesystem::move() to rename a file.
if ( $renamed ) {
$local_file = $new_local_file;
} else {
Expand All @@ -3061,6 +3066,23 @@

return false;
}
} elseif ( ! empty( $type ) ) {
// The file type is not allowed by WordPress (e.g., SVG).
// Skip the upload gracefully to avoid error log spam.
Feedzy_Rss_Feeds_Log::debug(
// translators: %1$s is the MIME type, %2$s is the image source URL.
sprintf( __( 'Skipping image upload — file type "%1$s" is not allowed by WordPress: %2$s', 'feedzy-rss-feeds' ), $type, $img_source_url ),
Comment on lines +3069 to +3074
array(
'post_id' => $post_id,
'img_source_url' => $img_source_url,
'mime_type' => $type,
)
);

// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink
unlink( $local_file );

Check failure on line 3083 in includes/admin/feedzy-rss-feeds-import.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.WP.AlternativeFunctions.unlink_unlink

unlink() is discouraged. Use wp_delete_file() to delete a file.

return false;
}

$file_array['tmp_name'] = $local_file;
Expand All @@ -3078,7 +3100,7 @@
);

// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink
unlink( $file_array['tmp_name'] );

Check failure on line 3103 in includes/admin/feedzy-rss-feeds-import.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.WP.AlternativeFunctions.unlink_unlink

unlink() is discouraged. Use wp_delete_file() to delete a file.

return false;
}
Expand Down Expand Up @@ -3135,7 +3157,7 @@

if (
( isset( $_POST['nonce'] ) && isset( $_POST['tab'] ) ) &&
wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), sanitize_text_field( $_POST['tab'] ) )

Check warning on line 3160 in includes/admin/feedzy-rss-feeds-import.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.Security.ValidatedSanitizedInput.MissingUnslash

$_POST['tab'] not unslashed before sanitization. Use wp_unslash() or similar
) {
if ( ! empty( $_POST['fz_cron_schedule'] ) ) {
$schedule = sanitize_text_field( wp_unslash( $_POST['fz_cron_schedule'] ) );
Expand Down Expand Up @@ -3388,7 +3410,7 @@
public function save_tab_settings( $settings, $tab ) {
if (
! isset( $_POST['nonce'] ) ||
! wp_verify_nonce( sanitize_text_field( $_POST['nonce'] ), $tab )

Check warning on line 3413 in includes/admin/feedzy-rss-feeds-import.php

View workflow job for this annotation

GitHub Actions / WordPress.org Guidelines Check

WordPress.Security.ValidatedSanitizedInput.MissingUnslash

$_POST['nonce'] not unslashed before sanitization. Use wp_unslash() or similar
) {
return array();
}
Expand Down
Loading