diff mbox series

bitbake: git fetcher: use urllib quote ...

Message ID PR0P264MB1882D9E54AD24DF72B9E65E5E9869@PR0P264MB1882.FRAP264.PROD.OUTLOOK.COM
State New
Headers show
Series bitbake: git fetcher: use urllib quote ... | expand

Commit Message

CESTONARO Thilo March 22, 2023, 8:37 a.m. UTC
to use the path url-compatible. This needs to happen before the shell quotation happens.

Without this commit, spaces in the clone URL will be used as " " and not as "%20" which will fail.
This commit changes the " " in the URL to "%20" when it is a http or https url.

Signed-off-by: Thilo Cestonaro <thilo.cestonaro@thalesgroup.com>
---
 lib/bb/fetch2/git.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--
2.37.2

Comments

Michael Opdenacker March 22, 2023, 10:40 a.m. UTC | #1
Hi Thilo,


Thanks for the patch!


On 22.03.23 at 09:37, Thilo C. via lists.openembedded.org wrote:
> to use the path url-compatible. This needs to happen before the shell 
> quotation happens.
>
> Without this commit, spaces in the clone URL will be used as " " and 
> not as "%20" which will fail.
> This commit changes the " " in the URL to "%20" when it is a http or 
> https url.
>
> Signed-off-by: Thilo Cestonaro <thilo.cestonaro@thalesgroup.com>


Oops, are you sure it applies to the latest "master" branch? I tried and 
it didn't, though I don't see why...


Another issue with your patch is the commit author name, which will be 
"Thilo C. via lists.openembedded.org 
<thilo.cestonaro=thalesgroup.com@lists.openembedded.org>" instead of 
"Thilo Cestonaro <thilo.cestonaro@thalesgroup.com>".


See 
https://www.openembedded.org/wiki/How_to_submit_a_patch_to_OpenEmbedded#Fixing_your_From_identity 
for details and a solution.


Don't hesitate to try to send the patch again to me privately before 
resending to the mailing list...


Thanks again
Cheers
Michael.
Alexandre Belloni March 24, 2023, 10:13 a.m. UTC | #2
Hello,

This doesn't apply on master, can you rebase?

Thanks

On 22/03/2023 08:37:15+0000, Thilo C. via lists.openembedded.org wrote:
> to use the path url-compatible. This needs to happen before the shell quotation happens.
> 
> Without this commit, spaces in the clone URL will be used as " " and not as "%20" which will fail.
> This commit changes the " " in the URL to "%20" when it is a http or https url.
> 
> Signed-off-by: Thilo Cestonaro <thilo.cestonaro@thalesgroup.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 578edc59..dc7f848d 100644
> --- a/lib/bb/fetch2/git.py
> +++ b/lib/bb/fetch2/git.py
> @@ -66,6 +66,7 @@ import re
>  import shlex
>  import subprocess
>  import tempfile
> +import urllib
>  import bb
>  import bb.progress
>  from contextlib import contextmanager
> @@ -697,7 +698,12 @@ class Git(FetchMethod):
>              username = ud.user + '@'
>          else:
>              username = ""
> -        return "%s://%s%s%s" % (ud.proto, username, ud.host, ud.path)
> +
> +        path = ud.path
> +        if ud.proto in [ 'http', 'https' ]:
> +            path = urllib.parse.quote(ud.path)
> +
> +        return "%s://%s%s%s" % (ud.proto, username, ud.host, path)
> 
>      def _revision_key(self, ud, d, name):
>          """
> --
> 2.37.2
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#14612): https://lists.openembedded.org/g/bitbake-devel/message/14612
> Mute This Topic: https://lists.openembedded.org/mt/97773918/3617179
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
CESTONARO Thilo April 19, 2023, 12:22 p.m. UTC | #3
Hi Michael

Sorry for the late answer.
I'm currently trying to be able to directly send the patches via Git but our IT does not allow it.

So here is another try with Outlook. And hopefully it does not change anything, like last time. As I think it was Outlooks fault that the patch did not apply.

This time I gzipped it. Hopefully this is ok for you!

Cheers
Thilo
Richard Purdie April 20, 2023, 11:43 a.m. UTC | #4
On Wed, 2023-03-22 at 08:37 +0000, Thilo C. via lists.openembedded.org
wrote:
> to use the path url-compatible. This needs to happen before the shell
> quotation happens.
> 
> Without this commit, spaces in the clone URL will be used as " " and
> not as "%20" which will fail.
> This commit changes the " " in the URL to "%20" when it is a http or
> https url.
> 
> Signed-off-by: Thilo Cestonaro <thilo.cestonaro@thalesgroup.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 578edc59..dc7f848d 100644
> --- a/lib/bb/fetch2/git.py
> +++ b/lib/bb/fetch2/git.py
> @@ -66,6 +66,7 @@ import re
>  import shlex
>  import subprocess
>  import tempfile
> +import urllib
>  import bb
>  import bb.progress
>  from contextlib import contextmanager
> @@ -697,7 +698,12 @@ class Git(FetchMethod):
>              username = ud.user + '@'
>          else:
>              username = ""
> -        return "%s://%s%s%s" % (ud.proto, username, ud.host,
> ud.path)
> +
> +        path = ud.path
> +        if ud.proto in [ 'http', 'https' ]:
> +            path = urllib.parse.quote(ud.path)
> +
> +        return "%s://%s%s%s" % (ud.proto, username, ud.host, path)
>  
>      def _revision_key(self, ud, d, name):
>          """

I'd like to ensure that we add test coverage to "bitbake-selftest" to
cover this situation (see lib/bb/tests/fetch.py).

We tend not to accept fixes like this unless we have test coverage to
prevent future regressions.

Cheers,

Richard
diff mbox series

Patch

diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 578edc59..dc7f848d 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -66,6 +66,7 @@  import re
 import shlex
 import subprocess
 import tempfile
+import urllib
 import bb
 import bb.progress
 from contextlib import contextmanager
@@ -697,7 +698,12 @@  class Git(FetchMethod):
             username = ud.user + '@'
         else:
             username = ""
-        return "%s://%s%s%s" % (ud.proto, username, ud.host, ud.path)
+
+        path = ud.path
+        if ud.proto in [ 'http', 'https' ]:
+            path = urllib.parse.quote(ud.path)
+
+        return "%s://%s%s%s" % (ud.proto, username, ud.host, path)

     def _revision_key(self, ud, d, name):
         """