From 9561084abaaa7ab7bf451fd33445f9f69b9f3517 Mon Sep 17 00:00:00 2001 From: ashubawork Date: Wed, 10 Jan 2024 14:38:34 +0200 Subject: [PATCH] - fixed stripslashes in tagline --- includes/core/um-filters-fields.php | 30 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/includes/core/um-filters-fields.php b/includes/core/um-filters-fields.php index 457b827a..744df5f9 100644 --- a/includes/core/um-filters-fields.php +++ b/includes/core/um-filters-fields.php @@ -851,39 +851,39 @@ add_filter( 'um_profile_field_filter_hook__multiselect','um_profile_field__selec */ function um_profile_field_filter_xss_validation( $value, $data, $type = '' ) { if ( ! empty( $value ) && is_string( $value ) ) { - $value = stripslashes( $value ); + $value = stripslashes( $value ); $data['validate'] = isset( $data['validate'] ) ? $data['validate'] : ''; - if ( 'text' == $type && ! in_array( $data['validate'], array( 'unique_email' ) ) || 'password' == $type ) { + if ( 'text' === $type && ! in_array( $data['validate'], array( 'unique_email' ), true ) || 'password' === $type ) { $value = esc_attr( $value ); - } elseif ( $type == 'url' ) { + } elseif ( 'url' === $type ) { $value = esc_url( $value ); - } elseif ( 'textarea' == $type ) { + } elseif ( 'textarea' === $type ) { if ( empty( $data['html'] ) ) { $value = wp_kses_post( $value ); } - } elseif ( 'rating' == $type ) { + } elseif ( 'rating' === $type ) { if ( ! is_numeric( $value ) ) { $value = 0; } else { - if ( $data['number'] == 5 ) { - if ( ! in_array( $value, range( 1, 5 ) ) ) { + if ( 5 === absint( $data['number'] ) ) { + if ( ! in_array( $value, range( 1, 5 ), true ) ) { $value = 0; } - } elseif ( $data['number'] == 10 ) { - if ( ! in_array( $value, range( 1, 10 ) ) ) { + } elseif ( 10 === $data['number'] ) { + if ( ! in_array( $value, range( 1, 10 ), true ) ) { $value = 0; } } } - } elseif ( 'select' == $type || 'radio' == $type ) { + } elseif ( 'select' === $type || 'radio' === $type ) { /** This filter is documented in includes/core/class-fields.php */ $option_pairs = apply_filters( 'um_select_options_pair', null, $data ); $array = empty( $data['options'] ) ? array() : $data['options']; - if ( $data['metakey'] == 'country' && empty( $array ) ) { + if ( 'country' === $data['metakey'] && empty( $array ) ) { $array = UM()->builtin()->get( 'countries' ); } @@ -893,6 +893,8 @@ function um_profile_field_filter_xss_validation( $value, $data, $type = '' ) { $arr = $array; } + $arr = array_map( 'stripslashes', $arr ); + if ( ! empty( $arr ) && ! in_array( $value, array_map( 'trim', $arr ) ) && empty( $data['custom_dropdown_options_source'] ) ) { $value = ''; } else { @@ -902,7 +904,7 @@ function um_profile_field_filter_xss_validation( $value, $data, $type = '' ) { } } } elseif ( ! empty( $value ) && is_array( $value ) ) { - if ( 'multiselect' == $type || 'checkbox' == $type ) { + if ( 'multiselect' === $type || 'checkbox' === $type ) { /** This filter is documented in includes/core/class-fields.php */ $option_pairs = apply_filters( 'um_select_options_pair', null, $data ); @@ -913,8 +915,8 @@ function um_profile_field_filter_xss_validation( $value, $data, $type = '' ) { } if ( ! empty( $arr ) && empty( $data['custom_dropdown_options_source'] ) ) { - $arr = wp_unslash( $arr ); - $arr = wp_slash( array_map( 'trim', $arr ) ); + $arr = wp_unslash( $arr ); + $arr = wp_slash( array_map( 'trim', $arr ) ); $value = array_intersect( $value, $arr ); }