Compare-View is broken when branch name contains slash ("/")
My branches are named like "feature/[featurename]" or "bugfix/[bugfixname]" but when I compare such a branch by pressing the "Compare" button, Gitlab returns 404. The URL is
http://gitlab/[group]/[project]/compare/master...bugfix%2Fbugfixname
When I change the URL to
http://gitlab/[group]/[project]/compare/master...bugfix/bugfixname
it works.
Designs
- Show closed items
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- Author
I noticed that the deletion of a branch (by button) also doesn't work. It seems that all branch names in URL needs to be decoded.
This is similar to #1363 (closed). The upgrade from Rails v4.1.2 to v4.1.9 (76aad9b7) caused slashes in a model ID to be escaped automatically. The Rails change in question is here:
https://github.com/rails/rails/commit/8a067640e6fe222022dc77bb63d5da37ef75a189
Upon reading more, I realize that an easier way to fix these issues may be to use wildcard segments rather than override
namespace_project_compare_path
.- Author
I upvote this bug, because it is urgent for me. +1
@mike-reiche I think a quick fix is here:
diff --git a/config/routes.rb b/config/routes.rb index 4b38ded..2d8a112 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -384,7 +384,7 @@ Gitlab::Application.routes.draw do end end - get '/compare/:from...:to' => 'compare#show', :as => 'compare', + get '/compare/*from...*to' => 'compare#show', :as => 'compare', :constraints => { from: /.+/, to: /.+/ } resources :snippets, constraints: { id: /\d+/ } do
In the omnibus version, you can try editing
/opt/gitlab/embedded/service/gitlab-rails/config/routes.rb
and restarting.Can you verify it works?
I'll submit a MR for this.
- Stan Hu mentioned in merge request !582 (merged)
mentioned in merge request !582 (merged)
- Stan Hu mentioned in issue #1438 (closed)
mentioned in issue #1438 (closed)
- Author
@stanhu I upgraded to 7.11.4, but this bug still exists (also the DELETE issue). I checked the source code of your commits and restarted gitlab.
- username-removed-128462 Status changed to reopened
Status changed to reopened
@mike-reiche, may I ask if you are using Passenger or Apache in front of your GitLab installation?
- Author
Apache2 as reverse proxy.
<Location /> Order deny,allow Allow from all ProxyPassReverse http://127.0.0.1:8080 </Location>
You may want to add:
AllowEncodedSlashes NoDecode
See:
- username-removed-128462 Status changed to closed
Status changed to closed
- Author
Thank you very much. I added the directive and both compare and deletion are working again.
- username-removed-128462 mentioned in issue #1804 (closed)
mentioned in issue #1804 (closed)
- username-removed-199614 mentioned in issue #1359 (closed)
mentioned in issue #1359 (closed)
- username-removed-443319 mentioned in issue #10772 (closed)
mentioned in issue #10772 (closed)
The link is broken :(
- username-removed-799444 Mentioned in issue gitlab-recipes#60
Mentioned in issue gitlab-recipes#60
- username-removed-444214 mentioned in issue gitlab-recipes#60
mentioned in issue gitlab-recipes#60