0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

🐛 escape blog title for mail header (#8453)

closes #8436

- this is how the from field looks like "blog title <owner@blog.com>"
- so if you set your blog title with double quotes, it throws a syntax error from the smtp library
This commit is contained in:
Katharina Irrgang 2017-05-12 14:34:22 +02:00 committed by kirrg001
parent 37e28cb6ef
commit 524cc4c343
2 changed files with 8 additions and 1 deletions

View file

@ -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 + '>';
}

View file

@ -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" <ghost@default.com>');
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\\"" <ghost@default.com>');
});
it('should use mail.from if both from and fromaddress are present', function () {