drapcode-utility 1.5.8 → 1.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/format-fields/index.js +23 -8
- package/package.json +1 -1
|
@@ -115,7 +115,7 @@ var cleanXssValuesFromData = function (data, fields) {
|
|
|
115
115
|
try {
|
|
116
116
|
if (fields) {
|
|
117
117
|
fields.forEach(function (field) {
|
|
118
|
-
if (
|
|
118
|
+
if ([drapcode_constant_1.FieldTypes.large_text.id, drapcode_constant_1.FieldTypes.markdown.id].includes(field.type))
|
|
119
119
|
exceptionFields.push(field.fieldName);
|
|
120
120
|
});
|
|
121
121
|
}
|
|
@@ -138,15 +138,30 @@ var processXssData = function (item, exceptionFields) {
|
|
|
138
138
|
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
139
139
|
var fieldName = keys_1[_i];
|
|
140
140
|
if (!exceptionFields.includes(fieldName)) {
|
|
141
|
-
|
|
142
|
-
item[fieldName] = item[fieldName].map(function (val) {
|
|
143
|
-
return domPurify.sanitize(val);
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
else
|
|
147
|
-
item[fieldName] = domPurify.sanitize(item[fieldName]);
|
|
141
|
+
item[fieldName] = sanitizeFieldValue(item[fieldName]);
|
|
148
142
|
}
|
|
149
143
|
}
|
|
150
144
|
}
|
|
151
145
|
return item;
|
|
152
146
|
};
|
|
147
|
+
var sanitizeFieldValue = function (value) {
|
|
148
|
+
if (value) {
|
|
149
|
+
if (Array.isArray(value)) {
|
|
150
|
+
value = value.map(function (val) { return sanitizeFieldValue(val); });
|
|
151
|
+
}
|
|
152
|
+
else if (typeof value === 'object' && value !== null) {
|
|
153
|
+
var tempItem = value;
|
|
154
|
+
var itemKeys = Object.keys(tempItem);
|
|
155
|
+
if (itemKeys.length) {
|
|
156
|
+
for (var _i = 0, itemKeys_1 = itemKeys; _i < itemKeys_1.length; _i++) {
|
|
157
|
+
var key = itemKeys_1[_i];
|
|
158
|
+
tempItem[key] = domPurify.sanitize(tempItem[key]);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
value = tempItem;
|
|
162
|
+
}
|
|
163
|
+
else
|
|
164
|
+
value = domPurify.sanitize(value);
|
|
165
|
+
}
|
|
166
|
+
return value;
|
|
167
|
+
};
|