PluginProbe
The Innovative Form Builder – IvyForms / 1.5.1
The Innovative Form Builder – IvyForms v1.5.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
← All changes | backend/src/Common/Helpers/FormImportValidator.php +24 -0 1.0 → 1.5.1 View file →
@@ -2,8 +2,9 @@
2 2
3 3 namespace IvyForms\Common\Helpers;
4 4
5 5 use IvyForms\Common\Exceptions\InvalidArgumentException;
6 +use IvyForms\Common\Sanitizer\Sanitizer;
6 7 use IvyForms\Services\Translations\BackendStrings;
7 8
8 9 class FormImportValidator
9 10 {
@@ -75,8 +76,21 @@
75 76 return $formArray;
76 77 }
77 78
78 79 /**
80 + * Remove style settings from an exported form payload.
81 + *
82 + * @param array<string, mixed> $formArray
83 + * @return array<string, mixed>
84 + */
85 + public static function stripStyleSettingsFromFormExport(array $formArray): array
86 + {
87 + unset($formArray['styleSettings']);
88 +
89 + return $formArray;
90 + }
91 +
92 + /**
79 93 * Prepare fields data for export.
80 94 *
81 95 * @param array<int, array<string, mixed>> $fields
82 96 * @param array<int, int> $idToIndexMap
@@ -253,8 +267,18 @@
253 267 'label' => $submitLabel,
254 268 'position' => 'default'
255 269 ]
256 270 ];
271 + }
272 +
273 + if (array_key_exists('styleSettings', $formArray)) {
274 + $sanitizedStyles = Sanitizer::sanitizeStyleSettings($formArray['styleSettings']);
275 + if ($sanitizedStyles === null) {
276 + unset($formArray['styleSettings']);
277 + }
278 + if ($sanitizedStyles !== null) {
279 + $formArray['styleSettings'] = $sanitizedStyles;
280 + }
257 281 }
258 282
259 283 return $formArray;
260 284 }