Message ID | 20250313155850.2924491-1-patrik.nordvall95@gmail.com |
---|---|
State | Accepted, archived |
Commit | be48024253b93215bb110cd1d05925e789ec9680 |
Headers | show |
Series | fetch2/git: Restore escape quoting for the git url when used | expand |
On Thu, 2025-03-13 at 16:58 +0100, Patrik Nordvall via lists.openembedded.org wrote: > This fixes a bug where escapes in the url path would not be properly > restored for the git commands in the git fetcher. For example, a > space which is encoded as '%20' was not properly encoded before the > clone command. > > e.g. > > SRC_URI="git://git.openembedded.org/bitbake%20example/bitbake;protocol=https" > > resulted in > git clone 'https://git.openembedded.org/bitbake example/bitbake' > > instead of > git clone 'https://git.openembedded.org/bitbake%20example/bitbake' > > Signed-off-by: Patrik Nordvall <patrik.nordvall95@gmail.com> > --- > lib/bb/fetch2/git.py | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py > index 5b678827e..aaf571eb6 100644 > --- a/lib/bb/fetch2/git.py > +++ b/lib/bb/fetch2/git.py > @@ -81,6 +81,7 @@ import shlex > import shutil > import subprocess > import tempfile > +import urllib > import bb > import bb.progress > from contextlib import contextmanager > @@ -828,7 +829,7 @@ class Git(FetchMethod): > username = ud.user + '@' > else: > username = "" > - return "%s://%s%s%s" % (ud.proto, username, ud.host, ud.path) > + return "%s://%s%s%s" % (ud.proto, username, ud.host, urllib.parse.quote(ud.path)) > > def _revision_key(self, ud, d, name): > """ Thanks for the patch. Could I convince you to add a test case to lib/bb/tests/fetch.py (run with bitbake-selftest) please? This is to try and ensure we don't regress this again! Cheers, Richard
diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py index 5b678827e..aaf571eb6 100644 --- a/lib/bb/fetch2/git.py +++ b/lib/bb/fetch2/git.py @@ -81,6 +81,7 @@ import shlex import shutil import subprocess import tempfile +import urllib import bb import bb.progress from contextlib import contextmanager @@ -828,7 +829,7 @@ class Git(FetchMethod): username = ud.user + '@' else: username = "" - return "%s://%s%s%s" % (ud.proto, username, ud.host, ud.path) + return "%s://%s%s%s" % (ud.proto, username, ud.host, urllib.parse.quote(ud.path)) def _revision_key(self, ud, d, name): """
This fixes a bug where escapes in the url path would not be properly restored for the git commands in the git fetcher. For example, a space which is encoded as '%20' was not properly encoded before the clone command. e.g. SRC_URI="git://git.openembedded.org/bitbake%20example/bitbake;protocol=https" resulted in git clone 'https://git.openembedded.org/bitbake example/bitbake' instead of git clone 'https://git.openembedded.org/bitbake%20example/bitbake' Signed-off-by: Patrik Nordvall <patrik.nordvall95@gmail.com> --- lib/bb/fetch2/git.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)