From 170f23bb248591a71f89a4cf8a91f1a44d778f91 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 12 Aug 2026 17:00:58 +0200 Subject: [PATCH] Fix Web UI being inaccessible with URLs ending with `.zip` (#40134) --- app/controllers/concerns/web_app_controller_concern.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/controllers/concerns/web_app_controller_concern.rb b/app/controllers/concerns/web_app_controller_concern.rb index 39fc948e909..5a540d17b44 100644 --- a/app/controllers/concerns/web_app_controller_concern.rb +++ b/app/controllers/concerns/web_app_controller_concern.rb @@ -6,6 +6,7 @@ module WebAppControllerConcern included do vary_by 'Accept, Accept-Language, Cookie' + before_action :adjust_format_for_zip_tlds before_action :redirect_unauthenticated_to_permalinks! before_action :set_referer_header before_action :redirect_to_tos_interstitial! @@ -46,6 +47,14 @@ module WebAppControllerConcern protected + # This endpoint will never serve zip files, but may serve paths ending with `.zip` due to the `.zip` TLD. + # When that happens from a browser, Rails will unfortunately determine the requested format to be `:zip` + # instead of `:html`, so override this. + # We don't just override `format` in all cases, because we want to handle `:json` as well. + def adjust_format_for_zip_tlds + request.format = :html if request.format == :zip + end + def redirect_to_tos_interstitial! return unless current_user&.require_tos_interstitial?