From 9ff512e35455939f02eaec2318e3acc77782fdeb Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 8 Nov 2021 12:17:12 -0300 Subject: Auto-convert github.com source URLs to use https This avoids having to fix every rockspec that uses github.com. See https://github.blog/2021-09-01-improving-git-protocol-security-github/ For more context, see: https://github.com/teal-language/tl/pull/494/ --- src/luarocks/fetch.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index c7f2d549..90e7c79e 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua @@ -502,6 +502,14 @@ function fetch.fetch_sources(rockspec, extract, dest_dir) assert(type(extract) == "boolean") assert(type(dest_dir) == "string" or not dest_dir) + -- auto-convert git://github.com URLs to use git+https + -- see https://github.blog/2021-09-01-improving-git-protocol-security-github/ + if rockspec.source.url:match("^git://github%.com/") + or rockspec.source.url:match("^git://www%.github%.com/") then + rockspec.source.url = rockspec.source.url:gsub("^git://", "git+https://") + rockspec.source.protocol = "git+https" + end + local protocol = rockspec.source.protocol local ok, proto if dir.is_basic_protocol(protocol) then @@ -522,6 +530,7 @@ function fetch.fetch_sources(rockspec, extract, dest_dir) return nil, "Can't download "..rockspec.source.url.." -- only downloading from "..cfg.only_sources_from end end + return proto.get_sources(rockspec, extract, dest_dir) end -- cgit v1.2.3-55-g6feb