From be0c47da58951e5ed48c43ea96e307fff93b850e Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 20 Nov 2019 20:45:33 -0800 Subject: [PATCH] Display an error if trying to save custom attributes with dot notation --- module/actor-sheet.js | 1 + module/item-sheet.js | 1 + 2 files changed, 2 insertions(+) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 06649da..e31b543 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -120,6 +120,7 @@ export class SimpleActorSheet extends ActorSheet { const formAttrs = expandObject(formData).data.attributes || {}; const attributes = Object.values(formAttrs).reduce((obj, v) => { let k = v["key"].trim(); + if ( /[\s\.]/.test(k) ) return ui.notifications.error("Attribute keys may not contain spaces or periods"); delete v["key"]; obj[k] = v; return obj; diff --git a/module/item-sheet.js b/module/item-sheet.js index 1d6b99e..d02cea3 100644 --- a/module/item-sheet.js +++ b/module/item-sheet.js @@ -104,6 +104,7 @@ export class SimpleItemSheet extends ItemSheet { const formAttrs = expandObject(formData).data.attributes || {}; const attributes = Object.values(formAttrs).reduce((obj, v) => { let k = v["key"].trim(); + if ( /[\s\.]/.test(k) ) return ui.notifications.error("Attribute keys may not contain spaces or periods"); delete v["key"]; obj[k] = v; return obj;