From 24a2208625cb5674c9c30324d6b64c902774fb2c Mon Sep 17 00:00:00 2001 From: kirrg001 Date: Thu, 31 Jan 2019 13:33:05 +0100 Subject: [PATCH] Fixed 500 when sending wrong mobiledoc structure refs #10438 --- core/server/models/post.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/server/models/post.js b/core/server/models/post.js index 40a9264363..fc319535d9 100644 --- a/core/server/models/post.js +++ b/core/server/models/post.js @@ -332,7 +332,14 @@ Post = ghostBookshelf.Model.extend({ // render mobiledoc to HTML if (this.hasChanged('mobiledoc') || !this.get('html')) { - this.set('html', converters.mobiledocConverter.render(JSON.parse(this.get('mobiledoc')))); + try { + this.set('html', converters.mobiledocConverter.render(JSON.parse(this.get('mobiledoc')))); + } catch (err) { + throw new common.errors.ValidationError({ + message: 'Invalid mobiledoc structure.', + help: 'https://docs.ghost.org/concepts/posts/' + }); + } } if (this.hasChanged('html') || !this.get('plaintext')) {