diff options
author | Shawn O. Pearce <sop@google.com> | 2009-03-25 13:58:14 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2009-03-25 13:58:14 -0700 |
commit | 722acefdc45a9d335793a79179c56c67f1dfed24 (patch) | |
tree | c9a6f60d06383aff200371a571b6cdcf5f416937 /git_config.py | |
parent | 13cc3844d7426d547a718946ecf365330cc0784c (diff) | |
download | git-repo-722acefdc45a9d335793a79179c56c67f1dfed24.tar.gz |
Produce a useful error if /ssh_info was HTML and not plain text
If /ssh_info is protected by an HTML based login page, we may get
back a "200 OK" response from the server with some HTML document
asking us to authenticate. This can't be parsed into a host name
and port number, so we shouldn't even try.
Valid host names and decimal port numbers cannot contain '<', but
an unexpected HTML login page would. So we test for '<' to give
us a fair indicator that the content isn't what we think it is,
and bail out.
Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'git_config.py')
-rw-r--r-- | git_config.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/git_config.py b/git_config.py index 971d1467..4829e2d3 100644 --- a/git_config.py +++ b/git_config.py | |||
@@ -284,6 +284,11 @@ class Remote(object): | |||
284 | info = urlopen(u).read() | 284 | info = urlopen(u).read() |
285 | if info == 'NOT_AVAILABLE': | 285 | if info == 'NOT_AVAILABLE': |
286 | raise UploadError('Upload over ssh unavailable') | 286 | raise UploadError('Upload over ssh unavailable') |
287 | if '<' in info: | ||
288 | # Assume the server gave us some sort of HTML | ||
289 | # response back, like maybe a login page. | ||
290 | # | ||
291 | raise UploadError('Cannot read %s:\n%s' % (u, info)) | ||
287 | 292 | ||
288 | self._review_protocol = 'ssh' | 293 | self._review_protocol = 'ssh' |
289 | self._review_host = info.split(" ")[0] | 294 | self._review_host = info.split(" ")[0] |