PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 2.12.8
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v2.12.8
2.12.8 2.12.7 2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 All 98 releases
← All changes | inc/ai-form-builder/field-mapping.php +19 -1 2.10.1 → 2.12.8 View file →
@@ -34,9 +34,13 @@
34 34 // Get params from request.
35 35 $params = $request->get_params();
36 36
37 37 // check parama is empty or not and is an array and consist form_data key.
38 - if ( empty( $params ) || ! is_array( $params ) || ! isset( $params['form_data'] ) || 0 === count( $params['form_data'] ) ) {
38 + // count() is guarded by is_array(): a non-array form_data is a TypeError in PHP 8,
39 + // and this endpoint is reachable with any JSON value. It falls through to the
40 + // invalid_form_data check below instead.
41 + if ( empty( $params ) || ! is_array( $params ) || ! isset( $params['form_data'] )
42 + || ( is_array( $params['form_data'] ) && 0 === count( $params['form_data'] ) ) ) {
39 43 return new WP_Error(
40 44 'srfm_ai_mapping_missing_form_data',
41 45 __( 'The AI form data is missing. Please try again.', 'sureforms' ),
42 46 [ 'status' => 400 ]
@@ -123,8 +127,22 @@
123 127 // caller could push a multi-MB string into the block's
124 128 // `_srfm_*` post meta. `wp_html_excerpt` strips HTML
125 129 // first, then truncates safely on word boundaries.
126 130 $merged_attributes['placeholder'] = wp_html_excerpt( sanitize_text_field( $question['placeholder'] ), 500 );
131 + }
132 +
133 + // Forward `className` (Additional CSS Class) to the block attrs.
134 + // Field blocks inherit core's className support and render it onto the
135 + // field wrapper (see inc/fields/base.php::set_properties()). Lands from
136 + // multiple callers (AI, MCP, HTML converter), so sanitize each token.
137 + if ( isset( $question['className'] ) && is_string( $question['className'] ) && '' !== $question['className'] ) {
138 + $classes = preg_split( '/\s+/', trim( $question['className'] ) );
139 + if ( is_array( $classes ) ) {
140 + $clean = implode( ' ', array_filter( array_map( 'sanitize_html_class', $classes ) ) );
141 + if ( '' !== $clean ) {
142 + $merged_attributes['className'] = $clean;
143 + }
144 + }
127 145 }
128 146
129 147 // Apply filter to modify field type.
130 148 $field_type = apply_filters( 'srfm_ai_field_modify_field_type', $question['fieldType'], $question, $is_conversational, $form_type );