From bdc9a52c19170a8e852429913ae2e3ad76661dc9 Mon Sep 17 00:00:00 2001 From: Kiran Ashok Date: Fri, 21 Apr 2023 12:36:22 +0530 Subject: [PATCH] Anchor tag placed with target="_blank" not opened in new tab in HTML viewer widget (#5883) * fix :: queryname not updating in header while editing and saving in sidebar * fix :: added hook to open a tags in new window * revert :: code --- frontend/src/Editor/Components/Html.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/src/Editor/Components/Html.jsx b/frontend/src/Editor/Components/Html.jsx index d192ec1f5b..fa803e74f3 100644 --- a/frontend/src/Editor/Components/Html.jsx +++ b/frontend/src/Editor/Components/Html.jsx @@ -13,6 +13,13 @@ export const Html = function ({ height, properties, styles, darkMode, dataCy }) useEffect(() => { setRawHtml(stringifyHTML); }, [stringifyHTML]); + DOMPurify.addHook('afterSanitizeAttributes', function (node) { + // set all elements owning target to target=_blank + if ('target' in node) { + node.setAttribute('target', '_blank'); + node.setAttribute('rel', 'noopener'); + } + }); return (