home: Don't assume user agent header is set for insecure_desktop_app.

The header may not be set - this leads to CI failures on 2.1.x branch,
but in any case is a real bug.
This commit is contained in:
Mateusz Mandera 2020-02-28 15:54:30 +01:00 committed by Tim Abbott
parent 23ba2b63c5
commit 2d55c7e0d5
2 changed files with 3 additions and 1 deletions

View File

@ -101,3 +101,5 @@ class CompatibilityTest(ZulipTestCase):
self.assertFalse(is_outdated_desktop_app('ZulipElectron/4.0.3 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Zulip/4.0.3 Chrome/66.0.3359.181 Electron/3.1.10 Safari/537.36'))
self.assertFalse(is_outdated_desktop_app('Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36'))
self.assertFalse(is_outdated_desktop_app(''))

View File

@ -228,7 +228,7 @@ def home_real(request: HttpRequest) -> HttpResponse:
debug_mode = settings.DEBUG,
test_suite = settings.TEST_SUITE,
poll_timeout = settings.POLL_TIMEOUT,
insecure_desktop_app = is_outdated_desktop_app(request.META["HTTP_USER_AGENT"]),
insecure_desktop_app = is_outdated_desktop_app(request.META.get("HTTP_USER_AGENT", "")),
login_page = settings.HOME_NOT_LOGGED_IN,
root_domain_uri = settings.ROOT_DOMAIN_URI,
max_file_upload_size = settings.MAX_FILE_UPLOAD_SIZE,