Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
register: Not all clients send a User-Agent header.
Alex Vandiver1f18fa65805d
diff --git a/zerver/lib/compatibility.py b/zerver/lib/compatibility.pyindex 11f4ec34a91..ddb1fa9f66b 100644--- a/zerver/lib/compatibility.py+++ b/zerver/lib/compatibility.py@@ -140,7 +140,7 @@ def is_unsupported_browser(user_agent: str) -> Tuple[bool, Optional[str]]:return (False, browser_name)-def is_pronouns_field_type_supported(user_agent_str: str) -> bool:+def is_pronouns_field_type_supported(user_agent_str: Optional[str]) -> bool:# In order to avoid users having a bad experience with these# custom profile fields disappearing after applying migration# 0421_migrate_pronouns_custom_profile_fields, we provide this@@ -150,6 +150,9 @@ def is_pronouns_field_type_supported(user_agent_str: str) -> bool:# TODO/compatibility(7.0): Because this is a relatively minor# detail, we can remove this compatibility hack once most users# have upgraded to a sufficiently new mobile client.+ if user_agent_str is None:+ return True+user_agent = parse_user_agent(user_agent_str)if user_agent["name"] != "ZulipMobile":return Truediff --git a/zerver/tests/test_event_system.py b/zerver/tests/test_event_system.pyindex fbad6864ceb..5b1cfbd4486 100644--- a/zerver/tests/test_event_system.py+++ b/zerver/tests/test_event_system.py@@ -50,6 +50,10 @@ from zerver.views.events_register import (class EventsEndpointTest(ZulipTestCase):+ def test_events_register_without_user_agent(self) -> None:+ result = self.client_post("/json/register", skip_user_agent=True)+ self.assert_json_success(result)+def test_events_register_endpoint(self) -> None:# This test is intended to get minimal coverage on thediff --git a/zerver/views/events_register.py b/zerver/views/events_register.pyindex 2fdd23dde82..8f3eada3367 100644--- a/zerver/views/events_register.py+++ b/zerver/views/events_register.py@@ -124,7 +124,9 @@ def events_register_backend(client = RequestNotes.get_notes(request).clientassert client is not None- pronouns_field_type_supported = is_pronouns_field_type_supported(request.headers["User-Agent"])+ pronouns_field_type_supported = is_pronouns_field_type_supported(+ request.headers.get("User-Agent")+ )ret = do_events_register(user_profile,realm,