index: limit file name length
This commit is contained in:
parent
709a6d24a9
commit
4a1b677243
|
@ -49,6 +49,8 @@ handleRequest = (event) ->
|
|||
handlePUT = (req, file) ->
|
||||
if not util.validateLength req
|
||||
return buildInvalidResponse "Maximum upload size: " + util.MAX_UPLOAD_SIZE
|
||||
if file.length > util.MAX_FILENAME_LENGTH
|
||||
return buildInvalidResponse "File name too long (max #{util.MAX_FILENAME_LENGTH})"
|
||||
|
||||
# Generate a valid ID first
|
||||
id = null
|
||||
|
|
|
@ -2,6 +2,8 @@ import { detect as detectBrowser } from 'detect-browser'
|
|||
|
||||
# Maimum upload size (in bytes)
|
||||
MAX_UPLOAD_SIZE = 10 * 1024 * 1024 # 10 MB
|
||||
# Maximum file name length
|
||||
MAX_FILENAME_LENGTH = 255 # bytes
|
||||
|
||||
# Validate content-length header
|
||||
validateLength = (req) ->
|
||||
|
@ -88,5 +90,6 @@ export {
|
|||
isBrowser,
|
||||
isText,
|
||||
progressText,
|
||||
humanFileSize
|
||||
humanFileSize,
|
||||
MAX_FILENAME_LENGTH
|
||||
}
|
Loading…
Reference in New Issue