Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

avatars: Clean up now-irrelevant assumptions.

Alex Vandiver41d1b417e70d
diff --git a/zerver/views/upload.py b/zerver/views/upload.py
index a33d74f7156..b8393ab1b24 100644
--- a/zerver/views/upload.py
+++ b/zerver/views/upload.py
@@ -285,9 +285,10 @@ def serve_local_avatar_unauthed(request: HttpRequest, path: str) -> HttpResponse
# We do not expect clients to hit this URL when using the S3
# backend; however, there is no reason to not serve the
# redirect to S3 where the content lives.
- return redirect(
- get_public_upload_root_url() + path + "?" + request.GET.urlencode(), permanent=True
- )
+ url = get_public_upload_root_url() + path
+ if request.GET.urlencode():
+ url += "?" + request.GET.urlencode()
+ return redirect(url, permanent=True)
local_path = os.path.join(settings.LOCAL_AVATARS_DIR, path)
assert_is_local_storage_path("avatars", local_path)
diff --git a/zerver/views/users.py b/zerver/views/users.py
index 0b1c1a0f893..773fe12f0b0 100644
--- a/zerver/views/users.py
+++ b/zerver/views/users.py
@@ -312,12 +312,9 @@ def avatar(
avatar_version = 1
url = get_gravatar_url(email, avatar_version, medium)
- # We can rely on the URL already having query parameters. Because
- # our templates depend on being able to use the ampersand to
- # add query parameters to our url, get_avatar_url does '?x=x'
- # hacks to prevent us from having to jump through decode/encode hoops.
assert url is not None
- url = append_url_query_string(url, request.META["QUERY_STRING"])
+ if request.META["QUERY_STRING"]:
+ url = append_url_query_string(url, request.META["QUERY_STRING"])
return redirect(url)