Skip to contentSkip to conversation

fetch2/ssh.py: decode path back for ssh

PATCH New Robert Yang 1 participant 1 message Apr 21, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fetch2/ssh.py: decode path back for ssh

The path has been encoded by urllib.parse.quote(), so decode it back for ssh.

Fixed when fetch from PREMIRRORS via ssh:

$ bitbake bonnie++ libsigc++-2.0 -cfetch

scp: /paht/to/downloads/libsigc%2B%2B-2.10.7.tar.xz: No such file or directory

---
 lib/bb/fetch2/ssh.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/bb/fetch2/ssh.py +4 -2
index 484453088..8d082b38c 100644
@@ -32,6 +32,7 @@ IETF secsh internet draft:
 
 import re, os
 from bb.fetch2 import check_network_access, FetchMethod, ParameterError, runfetchcmd
+import urllib
 
 
 __pattern__ = re.compile(r'''
@@ -70,6 +71,7 @@ class SSH(FetchMethod):
                 "git:// prefix with protocol=ssh", urldata.url)
         m = __pattern__.match(urldata.url)
         path = m.group('path')
+        path = urllib.parse.unquote(path)
         host = m.group('host')
         urldata.localpath = os.path.join(d.getVar('DL_DIR'),
                 os.path.basename(os.path.normpath(path)))
@@ -99,7 +101,7 @@ class SSH(FetchMethod):
 
         if path[0] != '~':
             path = '/%s' % path
-        path = path.replace("%3A", ":")
+        path = urllib.parse.unquote(path)
 
         fr += ':%s' % path
 
@@ -139,7 +141,7 @@ class SSH(FetchMethod):
 
         if path[0] != '~':
             path = '/%s' % path
-        path = path.replace("%3A", ":")
+        path = urllib.parse.unquote(path)
 
         cmd = 'ssh -o BatchMode=true %s %s [ -f %s ]' % (
             portarg,
Signature · 1 line
2.17.1