🐛 Fixed Content-Type for RSS feed (#20670)

fixes https://github.com/TryGhost/Ghost/issues/20634

- this sets the correct Content-Type (`application/rss+xml; charset=utf-8`) for the RSS Endpoint as mentioned in the referenced issue
- references for this Content-Type: https://datatracker.ietf.org/doc/id/draft-nottingham-rss-media-type-00 and https://stackoverflow.com/questions/595616/what-is-the-correct-mime-type-to-use-for-an-rss-feed
This commit is contained in:
Steffo 2024-08-07 12:09:54 +02:00 committed by GitHub
parent eb7024da34
commit 0d1916505f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 12 deletions

View File

@ -9,7 +9,7 @@ module.exports.render = function render(res, baseUrl, data) {
return rssCache
.getXML(baseUrl, rssData)
.then(function then(feedXml) {
res.set('Content-Type', 'text/xml; charset=UTF-8');
res.set('Content-Type', 'application/rss+xml; charset=UTF-8');
res.send(feedXml);
});
};

View File

@ -271,7 +271,7 @@ describe('Default Frontend routing', function () {
await request.get('/rss/')
.expect(200)
.expect('Cache-Control', testUtils.cacheRules.public)
.expect('Content-Type', 'text/xml; charset=utf-8')
.expect('Content-Type', 'application/rss+xml; charset=utf-8')
.expect(assertCorrectFrontendHeaders)
.expect((res) => {
res.text.should.match(/<!\[CDATA\[Start here for a quick overview of everything you need to know\]\]>/);
@ -283,7 +283,7 @@ describe('Default Frontend routing', function () {
await request.get('/author/ghost/rss/')
.expect(200)
.expect('Cache-Control', testUtils.cacheRules.public)
.expect('Content-Type', 'text/xml; charset=utf-8')
.expect('Content-Type', 'application/rss+xml; charset=utf-8')
.expect(assertCorrectFrontendHeaders)
.expect((res) => {
res.text.should.match(/<!\[CDATA\[Start here for a quick overview of everything you need to know\]\]>/);
@ -295,7 +295,7 @@ describe('Default Frontend routing', function () {
await request.get('/tag/getting-started/rss/')
.expect(200)
.expect('Cache-Control', testUtils.cacheRules.public)
.expect('Content-Type', 'text/xml; charset=utf-8')
.expect('Content-Type', 'application/rss+xml; charset=utf-8')
.expect(assertCorrectFrontendHeaders)
.expect((res) => {
res.text.should.match(/<!\[CDATA\[Start here for a quick overview of everything you need to know\]\]>/);
@ -461,7 +461,7 @@ describe('Default Frontend routing', function () {
await request.get(`/${settingsCache.get('public_hash')}/rss/`)
.expect(200)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect('Content-Type', 'text/xml; charset=utf-8')
.expect('Content-Type', 'application/rss+xml; charset=utf-8')
.expect(assertCorrectFrontendHeaders)
.expect((res) => {
res.text.should.match(/<!\[CDATA\[Start here for a quick overview of everything you need to know\]\]>/);
@ -472,7 +472,7 @@ describe('Default Frontend routing', function () {
await request.get(`/tag/getting-started/${settingsCache.get('public_hash')}/rss/`)
.expect(200)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect('Content-Type', 'text/xml; charset=utf-8')
.expect('Content-Type', 'application/rss+xml; charset=utf-8')
.expect(assertCorrectFrontendHeaders)
.expect((res) => {
res.text.should.match(/<!\[CDATA\[Start here for a quick overview of everything you need to know\]\]>/);

View File

@ -1294,7 +1294,7 @@ describe('Frontend behavior tests', function () {
return localUtils.mockExpress.invoke(app, req)
.then(function (response) {
response.statusCode.should.eql(200);
response.headers['content-type'].should.eql('text/xml; charset=UTF-8');
response.headers['content-type'].should.eql('application/rss+xml; charset=UTF-8');
});
});
@ -1448,7 +1448,7 @@ describe('Frontend behavior tests', function () {
routes: {
'/podcast/rss/': {
templates: ['podcast/rss'],
content_type: 'text/xml'
content_type: 'application/rss+xml'
},
'/cooking/': {
controller: 'channel',
@ -1560,7 +1560,7 @@ describe('Frontend behavior tests', function () {
.then(function (response) {
response.statusCode.should.eql(200);
response.template.should.eql('podcast/rss');
response.headers['content-type'].should.eql('text/xml; charset=utf-8');
response.headers['content-type'].should.eql('application/rss+xml');
response.body.match(/<link>/g).length.should.eql(2);
});
});

View File

@ -32,7 +32,7 @@ describe('RSS: Renderer', function () {
rssCacheStub.firstCall.args.should.eql(['/rss/', {}]);
res.set.calledOnce.should.be.true();
res.set.calledWith('Content-Type', 'text/xml; charset=UTF-8').should.be.true();
res.set.calledWith('Content-Type', 'application/rss+xml; charset=UTF-8').should.be.true();
res.send.calledOnce.should.be.true();
res.send.calledWith('dummyxml').should.be.true();
@ -51,7 +51,7 @@ describe('RSS: Renderer', function () {
rssCacheStub.firstCall.args.should.eql(['/rss/', {foo: 'bar'}]);
res.set.calledOnce.should.be.true();
res.set.calledWith('Content-Type', 'text/xml; charset=UTF-8').should.be.true();
res.set.calledWith('Content-Type', 'application/rss+xml; charset=UTF-8').should.be.true();
res.send.calledOnce.should.be.true();
res.send.calledWith('dummyxml').should.be.true();
@ -71,7 +71,7 @@ describe('RSS: Renderer', function () {
rssCacheStub.firstCall.args.should.eql(['/rss/', {foo: 'baz', fizz: 'buzz'}]);
res.set.calledOnce.should.be.true();
res.set.calledWith('Content-Type', 'text/xml; charset=UTF-8').should.be.true();
res.set.calledWith('Content-Type', 'application/rss+xml; charset=UTF-8').should.be.true();
res.send.calledOnce.should.be.true();
res.send.calledWith('dummyxml').should.be.true();