diff options
-rw-r--r-- | plugins/mod_http_file_share.lua | 4 | ||||
-rw-r--r-- | spec/scansion/http_upload.scs | 13 |
2 files changed, 17 insertions, 0 deletions
diff --git a/plugins/mod_http_file_share.lua b/plugins/mod_http_file_share.lua index 8a47b824..8d3310c9 100644 --- a/plugins/mod_http_file_share.lua +++ b/plugins/mod_http_file_share.lua @@ -48,6 +48,7 @@ local upload_errors = errors.init(module.name, namespace, { filetype = { type = "modify"; condition = "not-acceptable"; text = "File type not allowed" }; filesize = { type = "modify"; condition = "not-acceptable"; text = "File too large"; extra = {tag = st.stanza("file-too-large", {xmlns = namespace}):tag("max-file-size"):text(tostring(file_size_limit)) }; + filesizefmt = { type = "modify"; condition = "bad-request"; text = "File size must be positive integer"; } }; }); @@ -62,6 +63,9 @@ function may_upload(uploader, filename, filesize, filetype) -- > boolean, error return false, upload_errors.new("filename"); end + if not filesize or filesize < 0 or filesize % 1 ~= 0 then + return false, upload_errors.new("filesizefmt"); + end if filesize > file_size_limit then return false, upload_errors.new("filesize"); end diff --git a/spec/scansion/http_upload.scs b/spec/scansion/http_upload.scs index ab87ddee..f43fb3cb 100644 --- a/spec/scansion/http_upload.scs +++ b/spec/scansion/http_upload.scs @@ -38,6 +38,19 @@ Romeo receives: </iq> Romeo sends: + <iq to='upload.localhost' type='get' id='497c20dd-dda2-4feb-8199-7086e203de46' xml:lang='en'> + <request content-type='text/plain' filename='negative.dat' xmlns='urn:xmpp:http:upload:0' size='-1000'/> + </iq> + +Romeo receives: + <iq id='497c20dd-dda2-4feb-8199-7086e203de46' from='upload.localhost' type='error'> + <error type='modify'> + <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> + <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>File size must be positive integer</text> + </error> + </iq> + +Romeo sends: <iq to='upload.localhost' type='get' id='ac56d83f-a627-4732-8399-60492d1210b6' xml:lang='en'> <request content-type='text/plain' filename='invalid/filename.dat' xmlns='urn:xmpp:http:upload:0' size='1000'/> </iq> |