Skip to content

Commit

Permalink
Disallow HTTP URLs using : as path separator
Browse files Browse the repository at this point in the history
Previously URLs like `http://[email protected]:repo` were being parsed
incorrectly.
  • Loading branch information
omus committed Aug 1, 2017
1 parent 7c8a3e7 commit 6814e1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/libgit2/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Parse "GIT URLs" syntax (URLs and a scp-like syntax). For details see:
# https://git-scm.com/docs/git-clone#_git_urls_a_id_urls_a
const URL_REGEX = r"""
^(?:(?<scheme>ssh|git|https?)://)?
^(?:(?<scheme>ssh|git|https?)://)?+
(?:
(?<user>.*?)
(?:\:(?<password>.*?))?@
Expand Down
5 changes: 5 additions & 0 deletions test/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ end
@test m[:path] === nothing
end

@testset "HTTPS URL, invalid path" begin
m = match(LibGit2.URL_REGEX, "https://git@server:repo")
@test m === nothing
end

# scp-like syntax should have a colon separating the hostname from the path
@testset "scp-like syntax, invalid path" begin
m = match(LibGit2.URL_REGEX, "git@server/repo")
Expand Down

0 comments on commit 6814e1b

Please sign in to comment.