Skip to content

Fix upload redirections when project has moved

Stan Hu requested to merge sh-disable-formats-in-uploads-routes into master

Previously if a user attempted to click on a link to an attachment for a renamed project (e.g. https://gitlab-org/gitlab-ce/uploads/123.png), Rails would redirect the user to an erroneous URL (e.g. https://gitlab-org/gitlab-foss/uploads/123.png.png). Notice the redirect URL contains a redundant extension.

It turns out Rails 5 parses the extension of a route as the format (https://github.com/rails/rails/issues/28901#issuecomment-297747521), and the URL generator appends the format to the redirected route.

To fix this, we need to disable the format path parameter and explicitly set the format to nil. If we do not set the format to nil, the URL generator will append a query string (e.g ?format=png), which would still work but not necessary.

Closes #196232 (closed)

Edited by Stan Hu

Merge request reports

Loading