Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
report: Split hostname from port more carefully.
Anders Kaseorgd6ecb67d7557
diff --git a/zerver/logging_handlers.py b/zerver/logging_handlers.pyindex f5261f16ba5..7c22968821f 100644--- a/zerver/logging_handlers.py+++ b/zerver/logging_handlers.py@@ -5,6 +5,7 @@ import platformimport subprocessimport tracebackfrom typing import Any, Dict, Optional+from urllib.parse import SplitResultfrom django.conf import settingsfrom django.http import HttpRequest@@ -60,7 +61,7 @@ def add_request_metadata(report: Dict[str, Any], request: HttpRequest) -> None:report['data'] = {}try:- report['host'] = request.get_host().split(':')[0]+ report['host'] = SplitResult("", request.get_host(), "", "", "").hostnameexcept Exception:# request.get_host() will throw a DisallowedHost# exception if the host is invaliddiff --git a/zerver/views/report.py b/zerver/views/report.pyindex 4fc05cc0d0d..c408cf9c456 100644--- a/zerver/views/report.py+++ b/zerver/views/report.py@@ -2,6 +2,7 @@import loggingimport subprocessfrom typing import Any, Dict, Mapping, Optional+from urllib.parse import SplitResultfrom django.conf import settingsfrom django.http import HttpRequest, HttpResponse@@ -127,7 +128,7 @@ def report_error(request: HttpRequest, user_profile: UserProfile, message: str=Rqueue_json_publish('error_reports', dict(type = "browser",report = dict(- host = request.get_host().split(":")[0],+ host = SplitResult("", request.get_host(), "", "", "").hostname,ip_address = remote_ip,user_email = email,user_full_name = full_name,