mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -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:
parent
37e28cb6ef
commit
524cc4c343
2 changed files with 8 additions and 1 deletions
|
@ -30,7 +30,7 @@ GhostMailer.prototype.from = function () {
|
||||||
|
|
||||||
// If we do have a from address, and it's just an email
|
// If we do have a from address, and it's just an email
|
||||||
if (validator.isEmail(from)) {
|
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 + '>';
|
from = '"' + defaultBlogTitle + '" <' + from + '>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,6 +195,13 @@ describe('Mail: Ghostmailer', function () {
|
||||||
// Strip Port
|
// Strip Port
|
||||||
configUtils.set({url: 'http://default.com:2368/', mail: {from: null}});
|
configUtils.set({url: 'http://default.com:2368/', mail: {from: null}});
|
||||||
mailer.from().should.equal('"Test" <ghost@default.com>');
|
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 () {
|
it('should use mail.from if both from and fromaddress are present', function () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue