Merge pull request #5580 from ksonj/fix/non-standard-ssh

Fix detection of scp-style URIs to support non-standard SSH ports
This commit is contained in:
Eelco Dolstra 2021-11-18 12:30:29 +01:00 committed by GitHub
commit 0adced4b9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,7 +74,10 @@ std::string fixURI(std::string uri, EvalState & state, const std::string & defau
std::string fixURIForGit(std::string uri, EvalState & state) std::string fixURIForGit(std::string uri, EvalState & state)
{ {
static std::regex scp_uri("([^/].*)@(.*):(.*)"); /* Detects scp-style uris (e.g. git@github.com:NixOS/nix) and fixes
* them by removing the `:` and assuming a scheme of `ssh://`
* */
static std::regex scp_uri("([^/]*)@(.*):(.*)");
if (uri[0] != '/' && std::regex_match(uri, scp_uri)) if (uri[0] != '/' && std::regex_match(uri, scp_uri))
return fixURI(std::regex_replace(uri, scp_uri, "$1@$2/$3"), state, "ssh"); return fixURI(std::regex_replace(uri, scp_uri, "$1@$2/$3"), state, "ssh");
else else