diff options
author | Kim Alvefur <zash@zash.se> | 2025-03-23 12:21:19 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2025-03-23 12:21:19 +0100 |
commit | afd99708d60d640282966a5857f1483333339c77 (patch) | |
tree | 875cf49c0deecaab807eaa42c78a776642fd72e5 /plugins | |
parent | b9d4cc24df312019b90d6ee60447cfa13050805c (diff) | |
download | prosody-afd99708d60d640282966a5857f1483333339c77.tar.gz prosody-afd99708d60d640282966a5857f1483333339c77.zip |
mod_http_file_share: Fix off by one in Range response
See #1914
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_http_file_share.lua | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/plugins/mod_http_file_share.lua b/plugins/mod_http_file_share.lua index b5958572..ab9940b9 100644 --- a/plugins/mod_http_file_share.lua +++ b/plugins/mod_http_file_share.lua @@ -429,13 +429,14 @@ function handle_download(event, path) -- GET /uploads/:slot+filename local request_range = request.headers.range; local response_range; if request_range then + local last_byte = string.format("%d", tonumber(filesize) - 1); local range_start, range_end = request_range:match("^bytes=(%d+)%-(%d*)$") -- Only support resumption, ie ranges from somewhere in the middle until the end of the file. - if (range_start and range_start ~= "0") and (range_end == "" or range_end == filesize) then + if (range_start and range_start ~= "0") and (range_end == "" or range_end == last_byte) then local pos, size = tonumber(range_start), tonumber(filesize); local new_pos = pos < size and handle:seek("set", pos); if new_pos and new_pos < size then - response_range = "bytes "..range_start.."-"..filesize.."/"..filesize; + response_range = "bytes "..range_start.."-"..last_byte.."/"..filesize; filesize = string.format("%d", size-pos); else handle:close(); |