Fixed 500 when sending wrong mobiledoc structure

refs #10438
This commit is contained in:
kirrg001 2019-01-31 13:33:05 +01:00
parent 23f705d556
commit 24a2208625

View File

@ -332,7 +332,14 @@ Post = ghostBookshelf.Model.extend({
// render mobiledoc to HTML
if (this.hasChanged('mobiledoc') || !this.get('html')) {
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')) {