From 361d96f856fd2de89ef835c2a6c3e30020deefbe Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 28 Feb 2024 18:32:09 -0300 Subject: fix: refuse to use luasec < 1.1 This can happen if a distro-installed luasec is too old. See #1302 #1309 #1316 #1360 #1422 #1500 --- src/luarocks/fs/lua.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 29ffb255..71695701 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -9,6 +9,7 @@ local fs = require("luarocks.fs") local cfg = require("luarocks.core.cfg") local dir = require("luarocks.dir") local util = require("luarocks.util") +local vers = require("luarocks.core.vers") local pack = table.pack or function(...) return { n = select("#", ...), ... } end @@ -732,6 +733,11 @@ if socket_ok then local ltn12 = require("ltn12") local luasec_ok, https = pcall(require, "ssl.https") +if luasec_ok and not vers.compare_versions(https._VERSION, "1.0.3") then + luasec_ok = false + https = nil +end + local redirect_protocols = { http = http, https = luasec_ok and https, @@ -796,7 +802,7 @@ local function request(url, method, http, loop_control) -- luacheck: ignore 431 loop_control[url] = true return request(location, method, redirect_protocols[protocol], loop_control) else - return nil, "URL redirected to unsupported protocol - install luasec to get HTTPS support.", "https" + return nil, "URL redirected to unsupported protocol - install luasec >= 1.1 to get HTTPS support.", "https" end end return nil, err @@ -946,7 +952,7 @@ function fs_lua.download(url, filename, cache) return nil, err end if not downloader_warning then - util.warning("falling back to "..downloader.." - install luasec to get native HTTPS support") + util.warning("falling back to "..downloader.." - install luasec >= 1.1 to get native HTTPS support") downloader_warning = true end return fs.use_downloader(url, filename, cache) -- cgit v1.2.3-55-g6feb