@optimiser/common 1.0.399 → 1.0.400

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.
@@ -4760,14 +4760,27 @@ function IsAnotherObjectField(pageData, fieldName) {
4760
4760
  }
4761
4761
  return false;
4762
4762
  }
4763
- var CustomSanitizeHtml = function (dirtyHtml) {
4764
- var sanitizeHtmlContent = (0, sanitize_html_1.default)(dirtyHtml, {
4765
- allowedTags: sanitize_html_1.default.defaults.allowedTags,
4766
- allowedAttributes: {
4767
- '*': ['class'], // Allow 'class' attribute on all tags
4768
- } // QPC-9587 sanitized html allowed class attribute
4769
- });
4770
- return sanitizeHtmlContent.replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>');
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(/&amp;/g, '&')
4777
+ .replace(/&lt;/g, '<')
4778
+ .replace(/&gt;/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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.399",
3
+ "version": "1.0.400",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {