dl-wrapper: Fix support for URIs containing '+'
authorRobert Beckett <bbeckett@netvu.org.uk>
Mon, 4 Jun 2018 13:32:30 +0000 (14:32 +0100)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Mon, 4 Jun 2018 19:59:55 +0000 (21:59 +0200)
'+' is a valid character in a url. The current dl-wrapper gets the
URI scheme by dropping everything after the last '+' character, with
the intension of finding 'git' from e.g. 'git+https://uri'.

If a uri has a '+' anywhere in it, it ends up using too much of the
string as a scheme, and fails to match the handler properly.

An example of where this form of URI is used is when using deploy tokens
in gitlab. It uses a form like https://<username>:<password>@gitlab.com/<group>/<repo.git>
where username for deploy token is of the form 'gitlab+deploy-token-<number>'.

Use the %% operator to search backwards until the last '+' character when
dropping the rest of the string as we know that the first '+'
in the string should be the scheme.

Signed-off-by: Robert Beckett <bbeckett@netvu.org.uk>
Acked-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
support/download/dl-wrapper

index 8d6365e08d33af89be00a4bf33497bf50ff35068..4059c37ebc3b1145665e33884b8a48aa6baf0670 100755 (executable)
@@ -88,7 +88,7 @@ main() {
     download_and_check=0
     rc=1
     for uri in "${uris[@]}"; do
-        backend=${uri%+*}
+        backend=${uri%%+*}
         case "${backend}" in
             git|svn|cvs|bzr|file|scp|hg) ;;
             *) backend="wget" ;;