diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-05-19 19:46:40 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-05-23 20:38:24 -0500 |
commit | 4345bb8c507a11af694617187dea14284f48fb96 (patch) | |
tree | 20bc96bf6f90f8654492fb4e8b5cb1108e3d131d /lib/constraints | |
parent | 3cfcbcf35badfdb21244f7f16c8640cd83b49205 (diff) | |
download | gitlab-ce-4345bb8c507a11af694617187dea14284f48fb96.tar.gz |
Fix ambiguous routing issues by teaching router about reserved words
Diffstat (limited to 'lib/constraints')
-rw-r--r-- | lib/constraints/group_url_constrainer.rb | 6 | ||||
-rw-r--r-- | lib/constraints/project_url_constrainer.rb | 4 | ||||
-rw-r--r-- | lib/constraints/user_url_constrainer.rb | 6 |
3 files changed, 10 insertions, 6 deletions
diff --git a/lib/constraints/group_url_constrainer.rb b/lib/constraints/group_url_constrainer.rb index 5f379756c11..6fc1d56d7a0 100644 --- a/lib/constraints/group_url_constrainer.rb +++ b/lib/constraints/group_url_constrainer.rb @@ -1,9 +1,9 @@ class GroupUrlConstrainer def matches?(request) - id = request.params[:id] + full_path = request.params[:group_id] || request.params[:id] - return false unless DynamicPathValidator.valid?(id) + return false unless DynamicPathValidator.valid_group_path?(full_path) - Group.find_by_full_path(id, follow_redirects: request.get?).present? + Group.find_by_full_path(full_path, follow_redirects: request.get?).present? end end diff --git a/lib/constraints/project_url_constrainer.rb b/lib/constraints/project_url_constrainer.rb index 6f542f63f98..4c0aee6c48f 100644 --- a/lib/constraints/project_url_constrainer.rb +++ b/lib/constraints/project_url_constrainer.rb @@ -2,9 +2,9 @@ class ProjectUrlConstrainer def matches?(request) namespace_path = request.params[:namespace_id] project_path = request.params[:project_id] || request.params[:id] - full_path = namespace_path + '/' + project_path + full_path = [namespace_path, project_path].join('/') - return false unless DynamicPathValidator.valid?(full_path) + return false unless DynamicPathValidator.valid_project_path?(full_path) Project.find_by_full_path(full_path, follow_redirects: request.get?).present? end diff --git a/lib/constraints/user_url_constrainer.rb b/lib/constraints/user_url_constrainer.rb index 28159dc0dec..d16ae7f3f40 100644 --- a/lib/constraints/user_url_constrainer.rb +++ b/lib/constraints/user_url_constrainer.rb @@ -1,5 +1,9 @@ class UserUrlConstrainer def matches?(request) - User.find_by_full_path(request.params[:username], follow_redirects: request.get?).present? + full_path = request.params[:username] + + return false unless DynamicPathValidator.valid_user_path?(full_path) + + User.find_by_full_path(full_path, follow_redirects: request.get?).present? end end |