From 8b23a4bc24295f262c28a0625dca70d1cdfbcb28 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 24 Aug 2023 11:28:02 +0200 Subject: [PATCH] Clean props when copying creature -> lib prevents creature specific fields from leaking into libraries --- .../methods/copyPropertyToLibrary.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/imports/api/creature/creatureProperties/methods/copyPropertyToLibrary.js b/app/imports/api/creature/creatureProperties/methods/copyPropertyToLibrary.js index 46e7d024..b46205b9 100644 --- a/app/imports/api/creature/creatureProperties/methods/copyPropertyToLibrary.js +++ b/app/imports/api/creature/creatureProperties/methods/copyPropertyToLibrary.js @@ -132,6 +132,9 @@ function insertNodeFromProperty(propId, ancestors, order, method) { prop.order = order; } + // Clean the props + props = cleanProps(props); + // Insert the props as library nodes LibraryNodes.batchInsert(props); return prop; @@ -186,4 +189,11 @@ function assertSourceLibraryCopyPermission(props, method) { }); } +function cleanProps(props) { + return props.map(prop => { + let schema = LibraryNodes.simpleSchema(prop); + return schema.clean(prop); + }); +} + export default copyPropertyToLibrary;