@optimiser/common 1.0.399 → 1.0.401
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/dist/lib/utility.js +24 -10
- package/package.json +1 -1
package/dist/lib/utility.js
CHANGED
|
@@ -4760,14 +4760,27 @@ function IsAnotherObjectField(pageData, fieldName) {
|
|
|
4760
4760
|
}
|
|
4761
4761
|
return false;
|
|
4762
4762
|
}
|
|
4763
|
-
var CustomSanitizeHtml = function (dirtyHtml) {
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4763
|
+
var CustomSanitizeHtml = function (dirtyHtml, uiDataType) {
|
|
4764
|
+
// Define default sanitization options
|
|
4765
|
+
var defaultOptions = {
|
|
4766
|
+
allowedTags: sanitize_html_1.default.defaults.allowedTags || false, // Use an empty array if defaults are unavailable
|
|
4767
|
+
allowedAttributes: false
|
|
4768
|
+
};
|
|
4769
|
+
// Determine sanitization options based on uiDataType
|
|
4770
|
+
var sanitizeOptions = (uiDataType === 'texteditor') ? defaultOptions : {};
|
|
4771
|
+
try {
|
|
4772
|
+
// Sanitize the HTML content
|
|
4773
|
+
var sanitizedHtmlContent = (0, sanitize_html_1.default)(dirtyHtml, sanitizeOptions);
|
|
4774
|
+
// Replace HTML entities with their characters (use caution)
|
|
4775
|
+
return sanitizedHtmlContent
|
|
4776
|
+
.replace(/&/g, '&')
|
|
4777
|
+
.replace(/</g, '<')
|
|
4778
|
+
.replace(/>/g, '>');
|
|
4779
|
+
}
|
|
4780
|
+
catch (error) {
|
|
4781
|
+
console.error('Sanitization failed:', error);
|
|
4782
|
+
return ''; // Return empty string or handle error as needed
|
|
4783
|
+
}
|
|
4771
4784
|
};
|
|
4772
4785
|
/*
|
|
4773
4786
|
* Created by: Nirbhay as on 01-09-22
|
|
@@ -4839,7 +4852,7 @@ function ValidateUserInput(options) {
|
|
|
4839
4852
|
if (!field) return [3 /*break*/, 58];
|
|
4840
4853
|
//sanitizing Html and added IgnoreSanitizeHtml condition so that it can be ignored for certain fields
|
|
4841
4854
|
if (!field.IgnoreSanitizeHtml && IsStringValue(fieldData)) {
|
|
4842
|
-
inputFields[fieldName] = CustomSanitizeHtml(fieldData);
|
|
4855
|
+
inputFields[fieldName] = CustomSanitizeHtml(fieldData, field.UIDataType);
|
|
4843
4856
|
fieldData = inputFields[fieldName];
|
|
4844
4857
|
}
|
|
4845
4858
|
if (field.DisableValidateUserInput) {
|
|
@@ -5336,7 +5349,8 @@ function CheckConditionalField(field, record, action) {
|
|
|
5336
5349
|
break;
|
|
5337
5350
|
case "show-enabled-mandatory":
|
|
5338
5351
|
case "show-enabled-nonmandatory":
|
|
5339
|
-
|
|
5352
|
+
// Add this condition to exclude fields with UIDataType "location" for search address, as discussed with Shahzaib Sir.
|
|
5353
|
+
if (fieldData && field.Schema.UIDataType !== "location") {
|
|
5340
5354
|
msg = ((field.DisplayName || field.Schema.DisplayName) || field.Name) + ' is a hidden field and should not contain value.';
|
|
5341
5355
|
}
|
|
5342
5356
|
break;
|