diff --git a/core/server/mail/GhostMailer.js b/core/server/mail/GhostMailer.js index cc1a3f4d9b..c9d61f3d8a 100644 --- a/core/server/mail/GhostMailer.js +++ b/core/server/mail/GhostMailer.js @@ -30,7 +30,7 @@ GhostMailer.prototype.from = function () { // If we do have a from address, and it's just an email if (validator.isEmail(from)) { - defaultBlogTitle = settingsCache.get('title') || i18n.t('common.mail.title', {domain: this.getDomain()}); + defaultBlogTitle = settingsCache.get('title') ? settingsCache.get('title').replace(/"/g, '\\"') : i18n.t('common.mail.title', {domain: this.getDomain()}); from = '"' + defaultBlogTitle + '" <' + from + '>'; } diff --git a/core/test/unit/mail/GhostMailer_spec.js b/core/test/unit/mail/GhostMailer_spec.js index be1efbbdb7..60d10e9183 100644 --- a/core/test/unit/mail/GhostMailer_spec.js +++ b/core/test/unit/mail/GhostMailer_spec.js @@ -195,6 +195,13 @@ describe('Mail: Ghostmailer', function () { // Strip Port configUtils.set({url: 'http://default.com:2368/', mail: {from: null}}); mailer.from().should.equal('"Test" '); + + settingsCache.get.restore(); + sandbox.stub(settingsCache, 'get').returns('Test"'); + + // Escape title + configUtils.set({url: 'http://default.com:2368/', mail: {from: null}}); + mailer.from().should.equal('"Test\\"" '); }); it('should use mail.from if both from and fromaddress are present', function () {