Skip to contentSkip to conversation

bitbake: fetch2/git: Escape parentheses in git src name

PATCH In review Philippe Rivest 2 participants 3 messages Mar 10, 2024 – Apr 23, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bitbake: fetch2/git: Escape parentheses in git src name

From: Philippe Rivest <[email protected]>

FIXES [YOCTO #15404]

When using git fetcher on a repo with parentheses in its URL, the invocation of the git clone command will fail. The clone directory is not quoted thus the shell will return an error and won't execute the command.

(Bitbake rev: b5624ee5643d881afa004571a096a189ab5389b5)

Cc Philippe Rivest <[email protected]>
---
 bitbake/lib/bb/fetch2/git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bitbake/lib/bb/fetch2/git.py +1 -1
index b9dc576d47..6170da7fa6 100644
@@ -277,7 +277,7 @@ class Git(FetchMethod):
                     ud.unresolvedrev[name] = ud.revisions[name]
                 ud.revisions[name] = self.latest_revision(ud, d, name)
 
-        gitsrcname = '%s%s' % (ud.host.replace(':', '.'), ud.path.replace('/', '.').replace('*', '.').replace(' ','_'))
+        gitsrcname = '%s%s' % (ud.host.replace(':', '.'), ud.path.replace('/', '.').replace('*', '.').replace(' ','_').replace('(', '_').replace(')', '_'))
         if gitsrcname.startswith('.'):
             gitsrcname = gitsrcname[1:]
 
Signature · 1 line
2.40.0
#1 lore raw

Have you considered quoting the git clone paths in the command?

Would there be side effects? Also perhaps a more robust set of allowed characters would be better than increasing the list of replace calls?

Paulo Neves

Quoted 49 lines · Philippe Rivest

From: Philippe Rivest [<[email protected]>](mailto:[email protected]) FIXES [YOCTO #15404]

When using git fetcher on a repo with parentheses in its URL, the invocation of the git clone command will fail. The clone directory is not quoted thus the shell will return an error and won't execute the command.

(Bitbake rev: b5624ee5643d881afa004571a096a189ab5389b5)

Cc: Philippe Rivest [<[email protected]>](mailto:[email protected])
Signed-off-by: Philippe Rivest [<[email protected]>](mailto:[email protected])

---
 bitbake/lib/bb/fetch2/git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bitbake/lib/bb/fetch2/git.py +1 -2
index b9dc576d47..6170da7fa6 100644
@@ -277,7 +277,7 @@ class Git(FetchMethod):
                     ud.unresolvedrev[name] = ud.revisions[name]
                 ud.revisions[name] = self.latest_revision(ud, d, name)
 
-        gitsrcname = '%s%s' % (ud.host.replace(':', '.'), ud.path.replace('/', '.').replace('*', '.').replace(' ','_'))
+        gitsrcname = '%s%s' % (ud.host.replace(':', '.'), ud.path.replace('/', '.').replace('*', '.').replace(' ','_').replace('(', '_').replace(')', '_'))
         if gitsrcname.startswith('.'):
             gitsrcname = gitsrcname[1:]
 
--

2.40.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#15996):
https://lists.openembedded.org/g/bitbake-devel/message/15996
Mute This Topic:
https://lists.openembedded.org/mt/104839313/4454782
Group Owner:
[email protected] Unsubscribe:
https://lists.openembedded.org/g/bitbake-devel/unsub
[
[email protected]
]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

I considered quoting the clone directory. However, since the base implementation used replace calls, I followed suit. Whenever there was a parenthesis in the repo name, the clone would fail with the original implementation. There should not be any side effects: no released version of Bitbake/git fetcher has support for parentheses in in the repo name.

I agree that a replacement list/map is a more scalable solution, but might come with a higher risk of side effects. The same can be said for quoting the clone directory. Adding replace calls was a simple fix to a simple and narrow problem.