Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: sanitize tag alias as well

thecodrr9ba7ab3b25ae
diff --git a/packages/core/__tests__/tags.test.js b/packages/core/__tests__/tags.test.js
index c0247d2a4..29d928392 100644
--- a/packages/core/__tests__/tags.test.js
+++ b/packages/core/__tests__/tags.test.js
@@ -74,9 +74,9 @@ describe.each([
let note = db.notes.note(id);
await note[action](value);
let tag = db[collection].tag(value);
- await db[collection].rename(tag.id, value + "-new");
+ await db[collection].rename(tag.id, value + " ././..././new");
tag = db[collection].tag(tag.id);
- expect(db[collection].alias(tag.id)).toBe(value + "-new");
+ expect(db[collection].alias(tag.id)).toBe(value + "new");
}));
test(`remove a ${action}`, () =>
diff --git a/packages/core/collections/tags.js b/packages/core/collections/tags.js
index 81ae20746..d91e4f82d 100644
--- a/packages/core/collections/tags.js
+++ b/packages/core/collections/tags.js
@@ -46,6 +46,10 @@ export default class Tags extends Collection {
console.error(`No tag found. Tag id:`, tagId);
return;
}
+
+ newName = this.sanitize(newName);
+ if (!newName) throw new Error("Tag title cannot be empty.");
+
await this._db.settings.setAlias(tagId, newName);
await this._collection.addItem({ ...tag, alias: newName });
}