diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php index 4fdaf8cbba..8638cd5f7d 100644 --- a/classes/helpers/FrmAppHelper.php +++ b/classes/helpers/FrmAppHelper.php @@ -4599,4 +4599,24 @@ public static function no_gdpr_cookies() { $frm_settings = self::get_settings(); return $frm_settings->enable_gdpr && $frm_settings->no_gdpr_cookies; } + + /** + * Check if a string is valid UTF-8. + * + * @since x.x + * + * @param string $string The string to check. + * @return bool + */ + public static function is_valid_utf8( $string ) { + // wp_is_valid_utf8 is added in WP 6.9. + if ( function_exists( 'wp_is_valid_utf8' ) ) { + return wp_is_valid_utf8( $string ); + } + // As of WP 6.9, seems_utf8 is deprecated. + if ( function_exists( 'seems_utf8' ) ) { + return seems_utf8( $string ); + } + return false; + } } diff --git a/classes/helpers/FrmXMLHelper.php b/classes/helpers/FrmXMLHelper.php index 2a78ea95e8..4c63fe1bd2 100644 --- a/classes/helpers/FrmXMLHelper.php +++ b/classes/helpers/FrmXMLHelper.php @@ -1707,7 +1707,7 @@ public static function cdata( $str ) { FrmAppHelper::unserialize_or_decode( $str ); if ( is_array( $str ) ) { $str = json_encode( $str ); - } elseif ( seems_utf8( $str ) === false ) { + } elseif ( FrmAppHelper::is_valid_utf8( $str ) === false ) { $str = FrmAppHelper::maybe_utf8_encode( $str ); }