From bec966ab7d9ebb991266f614620f35bce511f17a Mon Sep 17 00:00:00 2001 From: marination <25857446+marination@users.noreply.github.com> Date: Wed, 12 Mar 2025 16:16:31 +0100 Subject: [PATCH] fix: Use DOMParser in `is_html` + Handle unparsable html string with jquery --- frappe/public/js/frappe/form/layout.js | 5 +++-- frappe/public/js/frappe/utils/utils.js | 16 ++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/frappe/public/js/frappe/form/layout.js b/frappe/public/js/frappe/form/layout.js index a7b139d13f..6caa979497 100644 --- a/frappe/public/js/frappe/form/layout.js +++ b/frappe/public/js/frappe/form/layout.js @@ -116,8 +116,9 @@ frappe.ui.form.Layout = class Layout { // wrap in a block if `html` does not contain html tags $html = $("
").text(html); } else { - $html = $(html); - $html.addClass("form-message border-bottom"); + // Wrap in a block just in case the string does not begin with a tag + // as Jquery assumes it to be a CSS selector and breaks. + $html = $("
").html(html); } // Add close button to block if not permanent diff --git a/frappe/public/js/frappe/utils/utils.js b/frappe/public/js/frappe/utils/utils.js index eabf37dada..ae4f223c19 100644 --- a/frappe/public/js/frappe/utils/utils.js +++ b/frappe/public/js/frappe/utils/utils.js @@ -157,16 +157,12 @@ Object.assign(frappe.utils, { is_html: function (txt) { if (!txt) return false; - if ( - txt.indexOf("
") == -1 && - txt.indexOf(" node.nodeType === 1); }, is_mac: function () { return window.navigator.platform === "MacIntel";