Эх сурвалжийг харах

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>
Shawn O. Pearce 17 жил өмнө
parent
commit
722acefdc4
1 өөрчлөгдсөн 5 нэмэгдсэн , 0 устгасан
  1. 5 0
      git_config.py

+ 5 - 0
git_config.py

@@ -284,6 +284,11 @@ class Remote(object):
         info = urlopen(u).read()
         if info == 'NOT_AVAILABLE':
           raise UploadError('Upload over ssh unavailable')
+        if '<' in info:
+          # Assume the server gave us some sort of HTML
+          # response back, like maybe a login page.
+          #
+          raise UploadError('Cannot read %s:\n%s' % (u, info))
 
         self._review_protocol = 'ssh'
         self._review_host = info.split(" ")[0]