diff --git a/background.js b/background.js index dccb28a..3343b60 100644 --- a/background.js +++ b/background.js @@ -8,7 +8,7 @@ async function handleClick(tab, e) { const store = {}; store[`create_${crypto.randomUUID()}`] = { name: tab.title, - notes: tab.url, + html_notes: `
${escapeHTML(tab.url)}`, attach: imgURL, filename: 'screenshot.png', }; @@ -22,6 +22,7 @@ async function handleClick(tab, e) { let inHandleChange = false; async function handleChange(e) { + // async functions allow concurrency. Add sketchy mutex. if (inHandleChange) { return; } @@ -61,7 +62,7 @@ async function create(cfg, task) { workspace: cfg['workspace'], assignee: cfg['assignee'], name: task.name, - notes: task.notes, + html_notes: task.html_notes, }, }; @@ -131,6 +132,12 @@ async function attach(cfg, task) { } } +function escapeHTML(unsafe) { + const div = document.createElement('div'); + div.innerText = unsafe; + return div.innerHTML; +} + const typeHandlers = new Map([ ['create', create], ['attach', attach],