From 80a86d763dea8adde06989c4f2a945c99c668097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Tue, 23 Feb 2021 21:27:15 +0000 Subject: [PATCH] Throw an error if the repo path contains the protocol (#1533) --- CHANGELOG.md | 4 ++++ src/Documenter.jl | 2 ++ test/deployconfig.jl | 1 + 3 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf31075cbf..82aa91b311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ * ![Enhancement][badge-enhancement] `deploydocs` now throws an error if something goes wrong with the Git invocations used to deploy to `gh-pages`. ([#1529][github-1529]) +* ![Bugfix][badge-bugfix] A bad `repo` argument to `deploydocs` containing a protocol now throws an error instead of being misinterpreted. ([#1531][github-1531], [#1533][github-1533]) + ## Version `v0.26.2` * ![Enhancement][badge-enhancement] `doctest()` no longer throws an error if cleaning up the temporary directory fails for some reason. ([#1513][github-1513], [#1526][github-1526]) @@ -756,6 +758,8 @@ [github-1526]: https://github.com/JuliaDocs/Documenter.jl/pull/1526 [github-1527]: https://github.com/JuliaDocs/Documenter.jl/pull/1527 [github-1529]: https://github.com/JuliaDocs/Documenter.jl/pull/1529 +[github-1531]: https://github.com/JuliaDocs/Documenter.jl/issues/1531 +[github-1533]: https://github.com/JuliaDocs/Documenter.jl/pull/1533 [julia-38079]: https://github.com/JuliaLang/julia/issues/38079 diff --git a/src/Documenter.jl b/src/Documenter.jl index 2786f33c3b..7ec8576825 100644 --- a/src/Documenter.jl +++ b/src/Documenter.jl @@ -697,6 +697,8 @@ Disassemble repo address into user, host, and path to repo. If no user is given, "git". Reassemble user, host and path into an upstream to `git push` to. """ function user_host_upstream(repo) + # If the repo path contains the protocol, throw immediately an error. + occursin(r"^[a-z]+://", repo) && error("The repo path $(repo) should not contain the protocol") #= the regex has three parts: (?:([^@]*)@)? matches any number of characters up to the first "@", if present, capturing only the characters before the "@" - this captures the username diff --git a/test/deployconfig.jl b/test/deployconfig.jl index 8ad1e67efc..6f68dbb765 100644 --- a/test/deployconfig.jl +++ b/test/deployconfig.jl @@ -522,6 +522,7 @@ end uhu = Documenter.user_host_upstream("user@subdom.long-page.com:/path/to/repo") @test uhu == ("user", "subdom.long-page.com", "user@subdom.long-page.com:path/to/repo") + @test_throws ErrorException Documenter.user_host_upstream("https://github.com/JuliaDocs/Documenter.jl.git") @test_throws ErrorException Documenter.user_host_upstream("user@subdom.long-page.com") end