check if POST values are actually set before sanitization

This commit is contained in:
Stefan Kalscheuer 2019-08-18 18:21:57 +02:00
parent 22373d2308
commit 0b07697db8

View File

@ -27,7 +27,9 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
StatifyBlacklist_Admin::cleanup_database(); StatifyBlacklist_Admin::cleanup_database();
} else { } else {
// Extract referer array. // Extract referer array.
$referer_str = sanitize_textarea_field( wp_unslash( $_POST['statifyblacklist']['referer']['blacklist'] ) ); if ( isset( $_POST['statifyblacklist']['referer']['blacklist'] ) ) {
$referer_str = sanitize_textarea_field( wp_unslash( $_POST['statifyblacklist']['referer']['blacklist'] ) );
}
if ( empty( trim( $referer_str ) ) ) { if ( empty( trim( $referer_str ) ) ) {
$referer = []; $referer = [];
} else { } else {
@ -45,7 +47,9 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
} }
// Extract target array. // Extract target array.
$target_str = sanitize_textarea_field( wp_unslash( $_POST['statifyblacklist']['target']['blacklist'] ) ); if ( isset( $_POST['statifyblacklist']['target']['blacklist'] ) ) {
$target_str = sanitize_textarea_field( wp_unslash( $_POST['statifyblacklist']['target']['blacklist'] ) );
}
if ( empty( trim( $target_str ) ) ) { if ( empty( trim( $target_str ) ) ) {
$target = []; $target = [];
} else { } else {
@ -63,7 +67,9 @@ if ( ! empty( $_POST['statifyblacklist'] ) ) {
} }
// Extract IP array. // Extract IP array.
$ip_str = sanitize_textarea_field( wp_unslash( $_POST['statifyblacklist']['ip']['blacklist'] ) ); if ( isset( $_POST['statifyblacklist']['ip']['blacklist'] ) ) {
$ip_str = sanitize_textarea_field( wp_unslash( $_POST['statifyblacklist']['ip']['blacklist'] ) );
}
if ( empty( trim( $ip_str ) ) ) { if ( empty( trim( $ip_str ) ) ) {
$ip = []; $ip = [];
} else { } else {