From 0c8373afb7916c8da2becd8850a918c355b9fc9c Mon Sep 17 00:00:00 2001 From: kirrg001 Date: Mon, 11 Mar 2019 17:25:45 +0100 Subject: [PATCH] Removed 'null' parsing in settings model refs #10582 - I don't think this is a good idea - If a user passses "null", we should treat it as a string - I am not aware of a use case why people have "null" in their database - If people send "null" via the API, we should respect this and accept a string --- core/server/models/settings.js | 5 ----- core/test/unit/models/settings_spec.js | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/core/server/models/settings.js b/core/server/models/settings.js index b011250359..0f3b550e51 100644 --- a/core/server/models/settings.js +++ b/core/server/models/settings.js @@ -116,7 +116,6 @@ Settings = ghostBookshelf.Model.extend({ // transform "0" to false // transform "false" to false - // transform "null" to null if (attrs.value === '0' || attrs.value === '1') { attrs.value = !!+attrs.value; } @@ -125,10 +124,6 @@ Settings = ghostBookshelf.Model.extend({ attrs.value = JSON.parse(attrs.value); } - if (attrs.value === 'null') { - attrs.value = null; - } - return attrs; } }, { diff --git a/core/test/unit/models/settings_spec.js b/core/test/unit/models/settings_spec.js index ee5c3c67ee..013e32df0b 100644 --- a/core/test/unit/models/settings_spec.js +++ b/core/test/unit/models/settings_spec.js @@ -29,7 +29,7 @@ describe('Unit: models/settings', function () { should.equal(returns.value, true); returns = setting.parse({key: 'something', value: 'null'}); - should.equal(returns.value, null); + should.equal(returns.value, 'null'); }); }); });