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