To date, bup has replaced \r and \n in remote repository paths with
spaces because the path is passed to the relevant commands as one of
the protocol's "line oriented" arguments rather than as an
explicitly (say bvec) encoded argument.
This avoids breaking the protocol and crashing or hanging, but it also
means that the remote will never be looking for the correct path in
these cases, so stop doing that and just reject the paths instead.
Thanks to Johannes Berg for the suggestion.
Signed-off-by: Rob Browning <
r...@defaultvalue.org>
Tested-by: Rob Browning <
r...@defaultvalue.org>
---
Pushed to main.
lib/bup/client.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/bup/client.py b/lib/bup/client.py
index 562c3663..9bda775c 100644
--- a/lib/bup/client.py
+++ b/lib/bup/client.py
@@ -326,16 +326,17 @@ class Client:
ctx.enter_context(self._transport)
self.conn = self._transport.conn
self._available_commands = self._get_available_commands()
- mangled_path = b''
- if self.path:
- mangled_path = re.sub(br'[\r\n]', b' ', self.path)
+ if self.path and (invalid := re.search(br'[\r\n]', self.path)):
+ bad_c = path_msg(match.group())
+ pm = path_msg(self.path)
+ raise Exception(f'Invalid {bad_c} in remote path {pm(self.path)}')
if create:
self._require_command(b'init-dir')
- self.conn.write(b'init-dir %s\n' % mangled_path)
+ self.conn.write(b'init-dir %s\n' % self.path)
self.check_ok()
elif self.path:
self._require_command(b'set-dir')
- self.conn.write(b'set-dir %s\n' % mangled_path)
+ self.conn.write(b'set-dir %s\n' % self.path)
self.check_ok()
if url.scheme == b'bup-rev':
legacy_id = _legacy_cache_id_for_remote(url.host, True)
--
2.47.3