PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 5.5.0
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v5.5.0
5.6.1 5.6.0 5.5.0 5.4.0 5.3.2 5.3.1 5.1.6 5.1.5 trunk 2.1.5 2.11 2.12 2.13 2.15 3.0.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.51 3.0.60 3.0.61 3.0.62 3.0.70 3.0.71 All 36 releases
← All changes | core/SanitizeHelper.class.php +37 -3 3.0.715.5.0 View file →
@@ -1,8 +1,10 @@
1 1 <?php
2 2
3 3 namespace forge12\contactform7\CF7DoubleOptIn;
4 4
5 +use Forge12\Shared\Logger;
6 +
5 7 if ( ! defined( 'ABSPATH' ) ) {
6 8 exit;
7 9 }
8 10
@@ -14,26 +16,58 @@
14 16 *
15 17 * @return array The sanitized array.
16 18 */
17 19 public static function sanitize_array( $data ): array {
20 + $logger = Logger::getInstance();
21 + $logger->info( 'Starting sanitization of an array.', [
22 + 'plugin' => 'double-opt-in',
23 + 'data_type' => gettype($data),
24 + ] );
25 +
18 26 if ( ! is_array( $data ) ) {
27 + $logger->warning( 'Provided data is not an array. Returning an empty array.', [
28 + 'plugin' => 'double-opt-in',
29 + 'data_type' => gettype($data),
30 + ] );
19 31 return [];
20 32 }
21 33
22 34 $sanitized_data = [];
23 35 foreach ( $data as $key => $value ) {
24 - if(!apply_filters('f12_cf7_doubleoptin_do_sanitize_key_'.$key, true) || $key === 'body') {
36 + $sanitized_key = sanitize_text_field( $key );
37 +
38 + $do_sanitize_key_filter = apply_filters('f12_cf7_doubleoptin_do_sanitize_key_'.$key, true);
39 + $logger->debug( 'Applying sanitization filter for key: ' . $key, [
40 + 'plugin' => 'double-opt-in',
41 + 'filter_result' => $do_sanitize_key_filter,
42 + ] );
43 +
44 + // Use a more explicit check for 'body' to avoid issues if the filter returns false for a different reason
45 + if ( ! $do_sanitize_key_filter || $key === 'body' ) {
25 46 $sanitized_data[$key] = $value;
47 + $logger->info( 'Skipping sanitization for key "' . $key . '" based on filter or key name.', [
48 + 'plugin' => 'double-opt-in',
49 + ] );
26 50 continue;
27 51 }
28 52
29 53 if ( is_array( $value ) ) {
30 - $sanitized_data[ sanitize_text_field( $key ) ] = self::sanitize_array( $value );
54 + $sanitized_data[ $sanitized_key ] = self::sanitize_array( $value );
55 + $logger->debug( 'Recursively sanitizing array value for key: ' . $sanitized_key, [
56 + 'plugin' => 'double-opt-in',
57 + ] );
31 58 } else {
32 - $sanitized_data[ sanitize_text_field( $key ) ] = wp_kses_post( $value );
59 + $sanitized_data[ $sanitized_key ] = wp_kses_post( $value );
60 + $logger->debug( 'Sanitizing string value for key "' . $sanitized_key . '" using wp_kses_post.', [
61 + 'plugin' => 'double-opt-in',
62 + ] );
33 63 }
34 64 }
65 +
66 + $logger->notice( 'Array sanitization completed successfully.', [
67 + 'plugin' => 'double-opt-in',
68 + ] );
35 69
36 70 return $sanitized_data;
37 71 }
38 72
39 73 }