From c48cc20fb9b0a5c996b8642089ee47c96f34453e Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Tue, 10 Aug 2021 10:44:24 +0200 Subject: [PATCH] Added limits to character strings, migration to remove image data urls from character pictures --- app/Model/Character/Characters.js | 24 ++++++++++++------------ app/server/migrations/migrations.js | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/app/Model/Character/Characters.js b/app/Model/Character/Characters.js index f60ef969..b236a4a3 100644 --- a/app/Model/Character/Characters.js +++ b/app/Model/Character/Characters.js @@ -3,18 +3,18 @@ Characters = new Mongo.Collection("characters"); Schemas.Character = new SimpleSchema({ //strings - name: {type: String, defaultValue: "", trim: false, optional: true}, - urlName: {type: String, defaultValue: "-", trim: false, optional: true}, - alignment: {type: String, defaultValue: "", trim: false, optional: true}, - gender: {type: String, defaultValue: "", trim: false, optional: true}, - race: {type: String, defaultValue: "", trim: false, optional: true}, - picture: {type: String, defaultValue: "", trim: true, optional: true}, - description: {type: String, defaultValue: "", trim: false, optional: true}, - personality: {type: String, defaultValue: "", trim: false, optional: true}, - ideals: {type: String, defaultValue: "", trim: false, optional: true}, - bonds: {type: String, defaultValue: "", trim: false, optional: true}, - flaws: {type: String, defaultValue: "", trim: false, optional: true}, - backstory: {type: String, defaultValue: "", trim: false, optional: true}, + name: {type: String, defaultValue: "", trim: false, optional: true, max: 128}, + urlName: {type: String, defaultValue: "-", trim: false, optional: true, max: 128}, + alignment: {type: String, defaultValue: "", trim: false, optional: true, max: 64}, + gender: {type: String, defaultValue: "", trim: false, optional: true, max: 64}, + race: {type: String, defaultValue: "", trim: false, optional: true, max: 64}, + picture: {type: String, defaultValue: "", trim: true, optional: true, max: 256}, + description: {type: String, defaultValue: "", trim: false, optional: true, max: 5000}, + personality: {type: String, defaultValue: "", trim: false, optional: true, max: 5000}, + ideals: {type: String, defaultValue: "", trim: false, optional: true, max: 5000}, + bonds: {type: String, defaultValue: "", trim: false, optional: true, max: 5000}, + flaws: {type: String, defaultValue: "", trim: false, optional: true, max: 5000}, + backstory: {type: String, defaultValue: "", trim: false, optional: true, max: 5000}, //attributes //ability scores diff --git a/app/server/migrations/migrations.js b/app/server/migrations/migrations.js index 383c8ec7..c44bf996 100644 --- a/app/server/migrations/migrations.js +++ b/app/server/migrations/migrations.js @@ -54,3 +54,28 @@ Migrations.add({ return; }, }); + +Migrations.add({ + version: 3, + name: "Removes data images from character pictures", + up: function() { + //update characters + Characters.find({}).forEach(function(char){ + if (char.tempHP) return; + Characters.update(char._id, {$set: { + "tempHP.adjustment": 0, + "tempHP.reset": "longRest", + }}); + }); + Characters.update({ + picture: /^data/ + }, { + $set: {picture: ''} + }, { + multi: true + }); + }, + down: function(){ + return; + }, +});