diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php
index fa9234fec0..d2f1351c36 100644
--- a/classes/helpers/FrmAppHelper.php
+++ b/classes/helpers/FrmAppHelper.php
@@ -929,7 +929,7 @@ public static function sanitize_request( $sanitize_method, &$values ) {
foreach ( $temp_values as $k => $val ) {
if ( isset( $sanitize_method[ $k ] ) ) {
- $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
+ $values[ $k ] = is_array( $val ) ? '' : call_user_func( $sanitize_method[ $k ], $val );
}
}
}
diff --git a/classes/models/FrmEntryValidate.php b/classes/models/FrmEntryValidate.php
index 4172b40080..c474f55a9b 100644
--- a/classes/models/FrmEntryValidate.php
+++ b/classes/models/FrmEntryValidate.php
@@ -478,10 +478,10 @@ public static function validate_field_types( &$errors, $posted_field, $value, $a
}
/**
- * @param array $errors
- * @param object $field
- * @param string $value
- * @param array $args
+ * @param array $errors
+ * @param object $field
+ * @param array|string $value
+ * @param array $args
*
* @return void
*/
@@ -494,7 +494,7 @@ public static function validate_phone_field( &$errors, $field, $value, $args ) {
$pattern = self::phone_format( $field );
- if ( ! preg_match( $pattern, $value ) ) {
+ if ( is_array( $value ) || ! preg_match( $pattern, $value ) ) {
$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
}
}
diff --git a/tests/phpunit/entries/test_FrmEntryValidate.php b/tests/phpunit/entries/test_FrmEntryValidate.php
index 5a39c3b176..ae38a3d6d1 100644
--- a/tests/phpunit/entries/test_FrmEntryValidate.php
+++ b/tests/phpunit/entries/test_FrmEntryValidate.php
@@ -32,6 +32,23 @@ public function test_validate() {
remove_filter( 'frm_validate_entry', $add_a_custom_error );
}
+ /**
+ * @covers FrmEntryValidate::validate_phone_field
+ */
+ public function test_validate_phone_field_rejects_array_value() {
+ $field = $this->factory->field->create_and_get(
+ array(
+ 'type' => 'phone',
+ 'form_id' => $this->factory->form->create(),
+ )
+ );
+ $errors = array();
+
+ FrmEntryValidate::validate_phone_field( $errors, $field, array( 'x' ), array( 'id' => $field->id ) );
+
+ $this->assertArrayHasKey( 'field' . $field->id, $errors );
+ }
+
/**
* @since 7.0
*
diff --git a/tests/phpunit/misc/test_FrmAppHelper.php b/tests/phpunit/misc/test_FrmAppHelper.php
index 84d0864862..5e4d6b9085 100644
--- a/tests/phpunit/misc/test_FrmAppHelper.php
+++ b/tests/phpunit/misc/test_FrmAppHelper.php
@@ -251,6 +251,17 @@ public function test_sanitize_request() {
$this->assertSame( $values['content'], wp_kses_post( $values['content'] ) );
}
+ /**
+ * @covers FrmAppHelper::sanitize_request
+ */
+ public function test_sanitize_request_ignores_array_value() {
+ $values = array( 'frm_action' => array( 'x' ) );
+
+ FrmAppHelper::sanitize_request( array( 'frm_action' => 'sanitize_title' ), $values );
+
+ $this->assertSame( '', $values['frm_action'] );
+ }
+
public function test_kses() {
$start_value = '';
$safe_value = 'Hello, click here';