Browse Source

fix: sanitise formula text before rendering

pull/7019/head
Pranav C 1 year ago
parent
commit
7f58ce3726
  1. 9
      packages/nc-gui/utils/urlUtils.ts

9
packages/nc-gui/utils/urlUtils.ts

@ -6,8 +6,15 @@ export const replaceUrlsWithLink = (text: string): boolean | string => {
} }
const rawText = text.toString() const rawText = text.toString()
// create a temporary element to sanitise the string
// by encoding any html code
const tempEl = document.createElement('div')
tempEl.textContent = rawText
const sanitisedText = tempEl.innerHTML
let found = false let found = false
const out = rawText.replace(/URI::\((.*?)\)/g, (_, url) => { const out = sanitisedText.replace(/URI::\((.*?)\)/g, (_, url) => {
found = true found = true
const a = document.createElement('a') const a = document.createElement('a')
a.textContent = url a.textContent = url

Loading…
Cancel
Save