mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
🐛 Fixed uploads of m4a files with audio/mp4 content type
fixes https://github.com/TryGhost/Ghost/issues/16301 Previously, audio/x-m4a was allowed but not audio/mp4. This meant uploads of m4a files failed in some cases e.g. Firefox on Windows.
This commit is contained in:
parent
d1657b90ea
commit
c5a4ee89c9
@ -41,6 +41,7 @@
|
|||||||
"audio/wav",
|
"audio/wav",
|
||||||
"audio/x-wav",
|
"audio/x-wav",
|
||||||
"audio/ogg",
|
"audio/ogg",
|
||||||
|
"audio/mp4",
|
||||||
"audio/x-m4a"
|
"audio/x-m4a"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -85,6 +85,34 @@ describe('Media API', function () {
|
|||||||
media.push(res.body.media[0].url.replace(config.get('url'), ''));
|
media.push(res.body.media[0].url.replace(config.get('url'), ''));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Can upload an m4a with audio/mp4 content type', async function () {
|
||||||
|
const res = await request.post(localUtils.API.getApiQuery('media/upload'))
|
||||||
|
.set('Origin', config.get('url'))
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.field('ref', 'audio_file_mp4')
|
||||||
|
.attach('file', path.join(__dirname, '/../../utils/fixtures/media/sample.m4a'), {filename: 'audio-mp4.m4a', contentType: 'audio/mp4'})
|
||||||
|
.expect(201);
|
||||||
|
|
||||||
|
res.body.media[0].url.should.match(new RegExp(`${config.get('url')}/content/media/\\d+/\\d+/audio-mp4.m4a`));
|
||||||
|
res.body.media[0].ref.should.equal('audio_file_mp4');
|
||||||
|
|
||||||
|
media.push(res.body.media[0].url.replace(config.get('url'), ''));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Can upload an m4a with audio/x-m4a content type', async function () {
|
||||||
|
const res = await request.post(localUtils.API.getApiQuery('media/upload'))
|
||||||
|
.set('Origin', config.get('url'))
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.field('ref', 'audio_file_x_m4a')
|
||||||
|
.attach('file', path.join(__dirname, '/../../utils/fixtures/media/sample.m4a'), {filename: 'audio-x-m4a.m4a', contentType: 'audio/x-m4a'})
|
||||||
|
.expect(201);
|
||||||
|
|
||||||
|
res.body.media[0].url.should.match(new RegExp(`${config.get('url')}/content/media/\\d+/\\d+/audio-x-m4a.m4a`));
|
||||||
|
res.body.media[0].ref.should.equal('audio_file_x_m4a');
|
||||||
|
|
||||||
|
media.push(res.body.media[0].url.replace(config.get('url'), ''));
|
||||||
|
});
|
||||||
|
|
||||||
it('Rejects non-media file type', async function () {
|
it('Rejects non-media file type', async function () {
|
||||||
const res = await request.post(localUtils.API.getApiQuery('media/upload'))
|
const res = await request.post(localUtils.API.getApiQuery('media/upload'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
|
BIN
ghost/core/test/utils/fixtures/media/sample.m4a
Normal file
BIN
ghost/core/test/utils/fixtures/media/sample.m4a
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user