mirror of
https://github.com/mastodon/mastodon.git
synced 2026-08-20 03:35:22 -05:00
Fix Web UI being inaccessible with URLs ending with .zip (#40134)
This commit is contained in:
@@ -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?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user