fix error with unexpected audio mime-type
we were looking for audio and video mime-types from a list. when recording on a mac, the type wasn't in our list. This change generalized the check by considering mime-type starting with "audio" to be audio, and "video" to be video. closes LA-868 refs LA-595 flag=none test plan: You'll need notorious running in chrome With RCE Enhancements turned off and again with it on - in the RCE select Media > upload/record media - go to the record tab - record a video > expect it to be in the RCE - repeat, but in the Record tab, click on the "webcam" button and select "No Video" - record some audio > expect it to be in the RCE - save > expect to be able to play both. - go to an assignment's submission - go to speedgrader - add a media comment - record audio - do it again for video > expect the comments to be viewable Change-Id: If2cdfd4dd689569ac539a079f270bd789f37a502 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/231542 QA-Review: Anju Reddy <areddy@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Product-Review: Ed Schiebel <eschiebel@instructure.com>
This commit is contained in:
parent
d15fba71e0
commit
1271571e3e
|
@ -40,6 +40,12 @@ export function mimeClass(file) {
|
|||
return file.mime_class
|
||||
} else {
|
||||
const contentType = getContentType(file)
|
||||
if (/^audio(\W|$)/.test(contentType)) {
|
||||
return 'audio'
|
||||
}
|
||||
if (/^video(\W|$)/.test(contentType)) {
|
||||
return 'video'
|
||||
}
|
||||
|
||||
return (
|
||||
{
|
||||
|
@ -71,25 +77,6 @@ export function mimeClass(file) {
|
|||
'application/x-zip-compressed': 'zip',
|
||||
'application/xml': 'code',
|
||||
'application/zip': 'zip',
|
||||
'audio/mp3': 'audio',
|
||||
'audio/mpeg': 'audio',
|
||||
'audio/basic': 'audio',
|
||||
'audio/mid': 'audio',
|
||||
'audio/3gpp': 'audio',
|
||||
'audio/x-aiff': 'audio',
|
||||
'audio/x-m4a': 'audio',
|
||||
'audio/x-mpegurl': 'audio',
|
||||
'audio/x-pn-realaudio': 'audio',
|
||||
'audio/x-wav': 'audio',
|
||||
'video/mpeg': 'video',
|
||||
'video/quicktime': 'video',
|
||||
'video/x-la-asf': 'video',
|
||||
'video/x-ms-asf': 'video',
|
||||
'video/x-msvideo': 'video',
|
||||
'video/x-sgi-movie': 'video',
|
||||
'video/3gpp': 'video',
|
||||
'video/mp4': 'video',
|
||||
'video/webm': 'video',
|
||||
'application/x-shockwave-flash': 'flash'
|
||||
}[contentType] ||
|
||||
file.mime_class ||
|
||||
|
|
|
@ -34,14 +34,16 @@
|
|||
*/
|
||||
export function cleanUrl(input) {
|
||||
let url = input
|
||||
if (input.match(/@/) && !input.match(/\//) && !input.match(/^mailto:/)) {
|
||||
url = 'mailto:' + input
|
||||
} else if (!input.match(/^\w+:\/\//) && !input.match(/^mailto:/) && !input.match(/^\//)) {
|
||||
url = 'http://' + input
|
||||
}
|
||||
if (input) {
|
||||
if (input.match(/@/) && !input.match(/\//) && !input.match(/^mailto:/)) {
|
||||
url = 'mailto:' + input
|
||||
} else if (!input.match(/^\w+:\/\//) && !input.match(/^mailto:/) && !input.match(/^\//)) {
|
||||
url = 'http://' + input
|
||||
}
|
||||
|
||||
if (url.indexOf('@') != -1 && url.indexOf('mailto:') != 0 && !url.match(/^http/)) {
|
||||
url = 'mailto:' + url
|
||||
if (url.indexOf('@') != -1 && url.indexOf('mailto:') != 0 && !url.match(/^http/)) {
|
||||
url = 'mailto:' + url
|
||||
}
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
|
|
@ -33,10 +33,17 @@ describe('fileEmbed', () => {
|
|||
it('uses content-type to identify video and audio', () => {
|
||||
const video = fileEmbed(getBaseFile({'content-type': 'video/mp4'}))
|
||||
const audio = fileEmbed(getBaseFile({'content-type': 'audio/mpeg'}))
|
||||
const notaudio = fileEmbed(
|
||||
getBaseFile({'content-type': 'x-audio/mpeg', preview_url: undefined})
|
||||
)
|
||||
const notvideo = fileEmbed(getBaseFile({'content-type': 'x-video/mp4', preview_url: undefined}))
|
||||
|
||||
assert.equal(video.type, 'video')
|
||||
assert.equal(video.id, 'maybe')
|
||||
assert.equal(audio.type, 'audio')
|
||||
assert.equal(audio.id, 'maybe')
|
||||
assert.equal(notaudio.type, 'file')
|
||||
assert.equal(notvideo.type, 'file')
|
||||
})
|
||||
|
||||
it('returns media entry id if provided', () => {
|
||||
|
|
|
@ -44,5 +44,10 @@ describe('contentInsertionUtils', () => {
|
|||
const output = contentInsertionUtils.cleanUrl(url)
|
||||
assert.equal(output, url)
|
||||
})
|
||||
|
||||
it('doesnt blow up with a missing url', () => {
|
||||
const output = contentInsertionUtils.cleanUrl(undefined)
|
||||
assert.equal(output, undefined)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue