From e250dfc1054d036457dc0a818893653471dbc33f Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Thu, 12 Dec 2024 05:59:14 +0100 Subject: [PATCH] Updates --- package-shared/functions/backend/db/addDbEntry.js | 5 +++-- package-shared/functions/backend/db/updateDbEntry.js | 4 +++- package.json | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) 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": {