aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2021-11-08 12:17:12 -0300
committerHisham Muhammad <hisham@gobolinux.org>2021-11-08 12:17:12 -0300
commit9ff512e35455939f02eaec2318e3acc77782fdeb (patch)
tree1dded2480f9095975caa10041f9456b2f4ee5541
parent11ddae641f9f23a01291443bf2569104edb855e1 (diff)
downloadluarocks-9ff512e35455939f02eaec2318e3acc77782fdeb.tar.gz
luarocks-9ff512e35455939f02eaec2318e3acc77782fdeb.tar.bz2
luarocks-9ff512e35455939f02eaec2318e3acc77782fdeb.zip
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/
-rw-r--r--src/luarocks/fetch.lua9
1 files changed, 9 insertions, 0 deletions
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)
502 assert(type(extract) == "boolean") 502 assert(type(extract) == "boolean")
503 assert(type(dest_dir) == "string" or not dest_dir) 503 assert(type(dest_dir) == "string" or not dest_dir)
504 504
505 -- auto-convert git://github.com URLs to use git+https
506 -- see https://github.blog/2021-09-01-improving-git-protocol-security-github/
507 if rockspec.source.url:match("^git://github%.com/")
508 or rockspec.source.url:match("^git://www%.github%.com/") then
509 rockspec.source.url = rockspec.source.url:gsub("^git://", "git+https://")
510 rockspec.source.protocol = "git+https"
511 end
512
505 local protocol = rockspec.source.protocol 513 local protocol = rockspec.source.protocol
506 local ok, proto 514 local ok, proto
507 if dir.is_basic_protocol(protocol) then 515 if dir.is_basic_protocol(protocol) then
@@ -522,6 +530,7 @@ function fetch.fetch_sources(rockspec, extract, dest_dir)
522 return nil, "Can't download "..rockspec.source.url.." -- only downloading from "..cfg.only_sources_from 530 return nil, "Can't download "..rockspec.source.url.." -- only downloading from "..cfg.only_sources_from
523 end 531 end
524 end 532 end
533
525 return proto.get_sources(rockspec, extract, dest_dir) 534 return proto.get_sources(rockspec, extract, dest_dir)
526end 535end
527 536