From fdffc27bb67c422ae6ab60b650c597b3aa4d509a Mon Sep 17 00:00:00 2001 From: J Rao Date: Mon, 6 Mar 2023 21:21:09 +0800 Subject: [PATCH 1/2] Allow arbitrary labels to be added via web clipper --- src/routes/api/clipper.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/routes/api/clipper.js b/src/routes/api/clipper.js index 60914e979..e1500c2c0 100644 --- a/src/routes/api/clipper.js +++ b/src/routes/api/clipper.js @@ -75,7 +75,7 @@ function addClipping(req) { } function createNote(req) { - let {title, content, pageUrl, images, clipType} = req.body; + let {title, content, pageUrl, images, clipType, labels} = req.body; if (!title || !title.trim()) { title = `Clipped note from ${pageUrl}`; @@ -100,6 +100,13 @@ function createNote(req) { note.setLabel('pageUrl', pageUrl); note.setLabel('iconClass', 'bx bx-globe'); } + + if (labels) { + for (const labelName in labels) { + console.log('set label ' + labelName + ' on the new note!'); + note.setLabel(labelName, labels[labelName]); + } + } const rewrittenContent = processContent(images, note, content); From 2389ab30f84d752d2f867eb8109f3921a764a76a Mon Sep 17 00:00:00 2001 From: J Rao Date: Mon, 6 Mar 2023 21:28:09 +0800 Subject: [PATCH 2/2] sanitize label value --- src/routes/api/clipper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/api/clipper.js b/src/routes/api/clipper.js index e1500c2c0..d792ff38a 100644 --- a/src/routes/api/clipper.js +++ b/src/routes/api/clipper.js @@ -103,8 +103,8 @@ function createNote(req) { if (labels) { for (const labelName in labels) { - console.log('set label ' + labelName + ' on the new note!'); - note.setLabel(labelName, labels[labelName]); + const labelValue = htmlSanitizer.sanitize(labels[labelName]); + note.setLabel(labelName, labelValue); } }