summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-04-13 15:43:58 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-04-20 13:01:43 -0400
commit29604ff2c3d6fc81c3ac26b590f912fea15d58a6 (patch)
tree56f086f7a1e60eb50601a2d7eb8d6af725af2962 /lib
parent189c5347bef6c182ed00e2b845cdce5678abbbce (diff)
downloadgitlab-ce-29604ff2c3d6fc81c3ac26b590f912fea15d58a6.tar.gz
Add permission checking to UserReferenceFilter
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/markdown/user_reference_filter.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/gitlab/markdown/user_reference_filter.rb b/lib/gitlab/markdown/user_reference_filter.rb
index eaf4094338b..d6798ee2158 100644
--- a/lib/gitlab/markdown/user_reference_filter.rb
+++ b/lib/gitlab/markdown/user_reference_filter.rb
@@ -78,12 +78,16 @@ module Gitlab
%(<a href="#{url}" class="#{klass}">@#{user}</a>)
elsif namespace = Namespace.find_by(path: user)
if namespace.is_a?(Group)
- url = group_url(user, only_path: context[:only_path])
+ if user_can_read_group?(namespace)
+ url = group_url(user, only_path: context[:only_path])
+ %(<a href="#{url}" class="#{klass}">@#{user}</a>)
+ else
+ match
+ end
else
url = user_url(user, only_path: context[:only_path])
+ %(<a href="#{url}" class="#{klass}">@#{user}</a>)
end
-
- %(<a href="#{url}" class="#{klass}">@#{user}</a>)
else
match
end
@@ -112,6 +116,11 @@ module Gitlab
h.namespace_project_url(project.namespace, project,
only_path: context[:only_path])
end
+
+ def user_can_read_group?(group)
+ return false if context[:current_user].blank?
+ Ability.abilities.allowed?(context[:current_user], :read_group, group)
+ end
end
end
end