]> source.dussan.org Git - redmine.git/commitdiff
Fixed: issue details view discloses relations to issues that the user is not allowed...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 31 Jan 2009 13:22:29 +0000 (13:22 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 31 Jan 2009 13:22:29 +0000 (13:22 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2343 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb
app/views/issues/_relations.rhtml
test/functional/issues_controller_test.rb

index d333fe3cc8783720b43646e7d7eeef1b26a715bd..cbd2628004a81954f99219770fe7566485eec4fe 100644 (file)
@@ -54,6 +54,11 @@ class Issue < ActiveRecord::Base
   named_scope :visible, lambda {|*args| { :include => :project,
                                           :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } }
   
+  # Returns true if usr or current user is allowed to view the issue
+  def visible?(usr=nil)
+    (usr || User.current).allowed_to?(:view_issues, self.project)
+  end
+  
   def after_initialize
     if new_record?
       # set default values for new records only
index 7139210bc5c8a586c5f979b1b4d8cd886b5d391e..f99976f5cc32d0e759df0ea75c75dac6f362b81f 100644 (file)
@@ -8,7 +8,7 @@
 
 <% if @issue.relations.any? %>
 <table style="width:100%">
-<% @issue.relations.each do |relation| %>
+<% @issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation| %>
 <tr>
 <td><%= l(relation.label_for(@issue)) %> <%= "(#{lwr(:actionview_datehelper_time_in_words_day, relation.delay)})" if relation.delay && relation.delay != 0 %>
     <%= h(relation.other_issue(@issue).project) + ' - ' if Setting.cross_project_issue_relations? %> <%= link_to_issue relation.other_issue(@issue) %></td>
index 1097ca5d10f4392836154309f6b910199f6085e6..cc1c7740802dc65d6fff1ff1dcc13f9c3216695a 100644 (file)
@@ -324,6 +324,21 @@ class IssuesControllerTest < Test::Unit::TestCase
                                             :content => /Notes/ } }
   end
   
+  def test_show_should_not_disclose_relations_to_invisible_issues
+    Setting.cross_project_issue_relations = '1'
+    IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => 'relates')
+    # Relation to a private project issue
+    IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(4), :relation_type => 'relates')
+    
+    get :show, :id => 1
+    assert_response :success
+    
+    assert_tag :div, :attributes => { :id => 'relations' },
+                     :descendant => { :tag => 'a', :content => /#2$/ }
+    assert_no_tag :div, :attributes => { :id => 'relations' },
+                        :descendant => { :tag => 'a', :content => /#4$/ }
+  end
+  
   def test_new_routing
     assert_routing(
       {:method => :get, :path => '/projects/1/issues/new'},