diff --git a/package-shared/functions/backend/db/addDbEntry.js b/package-shared/functions/backend/db/addDbEntry.js index 7370157..0520980 100644 --- a/package-shared/functions/backend/db/addDbEntry.js +++ b/package-shared/functions/backend/db/addDbEntry.js @@ -2,7 +2,6 @@ const sanitizeHtml = require("sanitize-html"); const sanitizeHtmlOptions = require("../html/sanitizeHtmlOptions"); -const updateDb = require("./updateDbEntry"); const updateDbEntry = require("./updateDbEntry"); const _ = require("lodash"); const DB_HANDLER = require("../../../utils/backend/global-db/DB_HANDLER"); @@ -160,7 +159,9 @@ async function addDbEntry({ console.log("DSQL: Encrypted value =>", value); } - if (targetFieldSchema?.richText) { + const htmlRegex = /<[^>]+>/g; + + if (targetFieldSchema?.richText || String(value).match(htmlRegex)) { value = sanitizeHtml(value, sanitizeHtmlOptions); } diff --git a/package-shared/functions/backend/db/updateDbEntry.js b/package-shared/functions/backend/db/updateDbEntry.js index 95fa8cb..63f1329 100644 --- a/package-shared/functions/backend/db/updateDbEntry.js +++ b/package-shared/functions/backend/db/updateDbEntry.js @@ -98,7 +98,9 @@ async function updateDbEntry({ if (value == null || value == undefined) continue; - if (targetFieldSchema?.richText) { + const htmlRegex = /<[^>]+>/g; + + if (targetFieldSchema?.richText || String(value).match(htmlRegex)) { value = sanitizeHtml(value, sanitizeHtmlOptions); } diff --git a/package.json b/package.json index 09f4161..e70ac1a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/datasquirel", - "version": "2.9.8", + "version": "2.9.9", "description": "Cloud-based SQL data management tool", "main": "index.js", "bin": {