##// END OF EJS Templates
fix(svn): more binary protocol svn ssh fixes
super-admin -
r5333:545f9333 default
parent child Browse files
Show More
@@ -25,7 +25,6 b' import tempfile'
25 25 from subprocess import Popen, PIPE
26 26 import urllib.parse
27 27
28 from rhodecode.lib.str_utils import safe_bytes
29 28 from rhodecode_tools.lib.utils import safe_str
30 29 from .base import SshVcsServer
31 30
@@ -103,19 +102,27 b' class SubversionTunnelWrapper(object):'
103 102
104 103 def patch_first_client_response(self, response, **kwargs):
105 104 self.create_hooks_env()
106 data = response.copy()
107 data.update(kwargs)
108 data['url'] = self._svn_string(data['url'])
109 data['ra_client'] = self._svn_string(data['ra_client'])
110 data['client'] = data['client'] or ''
111 buffer_ = safe_bytes(
112 "( {version} ( {capabilities} ) {url}{ra_client}"
113 "( {client}) ) ".format(**data))
105
106 version = response['version']
107 capabilities = response['capabilities']
108 client = response['client'] or b''
109
110 url = self._svn_bytes(response['url'])
111 ra_client = self._svn_bytes(response['ra_client'])
112
113 buffer_ = b"( %b ( %b ) %b%b( %b) ) " % (
114 version,
115 capabilities,
116 url,
117 ra_client,
118 client
119 )
114 120 self.process.stdin.write(buffer_)
115 121
116 122 def fail(self, message):
117 print("( failure ( ( 210005 {message} 0: 0 ) ) )".format(
118 message=self._svn_string(message)))
123 fail_msg = b"( failure ( ( 210005 %b 0: 0 ) ) )" % self._svn_bytes(message)
124 sys.stdout.buffer.write(fail_msg)
125 sys.stdout.flush()
119 126 self.remove_configs()
120 127 self.process.kill()
121 128 return 1
@@ -123,10 +130,11 b' class SubversionTunnelWrapper(object):'
123 130 def interrupt(self, signum, frame):
124 131 self.fail("Exited by timeout")
125 132
126 def _svn_string(self, str_):
127 if not str_:
128 return ''
129 return f'{len(str_)}:{str_} '
133 def _svn_bytes(self, bytes_: bytes) -> bytes:
134 if not bytes_:
135 return b''
136
137 return f'{len(bytes_)}:'.encode() + bytes_ + b' '
130 138
131 139 def _read_first_client_response(self):
132 140 buffer_ = b""
General Comments 0
You need to be logged in to leave comments. Login now