For missing/invalid extensions, append the correct extension if we know it.

4chan will reject WebMs sent as ".jpg".
This commit is contained in:
ccd0 2015-10-24 10:56:40 -07:00
parent 746e89bb06
commit a265abc01a
2 changed files with 11 additions and 4 deletions

View File

@ -12,6 +12,15 @@ QR =
'swf': 'application/vnd.adobe.flash.movie'
'webm': 'video/webm'
extensionFromType:
'image/jpeg': 'jpg'
'image/png': 'png'
'image/gif': 'gif'
'application/pdf': 'pdf'
'application/vnd.adobe.flash.movie': 'swf'
'application/x-shockwave-flash': 'swf'
'video/webm': 'webm'
init: ->
return unless Conf['Quick Reply']

View File

@ -301,10 +301,8 @@ QR.post = class
saveFilename: ->
@file.newName = (@filename or '').replace /[/\\]/g, '-'
unless QR.validExtension.test @filename
# 4chan will truncate the filename if it has no extension,
# but it will always replace the extension by the correct one,
# so we suffix it with '.jpg' when needed.
@file.newName += '.jpg'
# 4chan will truncate the filename if it has no extension.
@file.newName += ".#{QR.extensionFromType[@file.type] or 'jpg'}"
updateFilename: ->
long = "#{@filename} (#{@filesize})"