diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 93bd6c050..d73258939 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -56,9 +56,9 @@ module IssuesHelper unless no_html label = content_tag('strong', label) - old_value = content_tag("i", old_value) if old_value - old_value = content_tag("strike", old_value) if old_value and !value - value = content_tag("i", value) if value + old_value = content_tag("i", h(old_value)) if old_value + old_value = content_tag("strike", h(old_value)) if old_value and !value + value = content_tag("i", h(value)) if value end if value diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index 924a874a3..2f5f2749f 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -28,6 +28,7 @@ class CustomField < ActiveRecord::Base validates_presence_of :name, :field_format validates_uniqueness_of :name + validates_format_of :name, :with => /^[\w\s\'\-]*$/i validates_inclusion_of :field_format, :in => FIELD_FORMATS.keys validates_presence_of :possible_values, :if => Proc.new { |field| field.field_format == "list" } diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb index b5c8ed6e7..0d6554f82 100644 --- a/app/models/enumeration.rb +++ b/app/models/enumeration.rb @@ -18,8 +18,9 @@ class Enumeration < ActiveRecord::Base before_destroy :check_integrity - validates_presence_of :opt, :name - validates_uniqueness_of :name, :scope => [:opt] + validates_presence_of :opt, :name + validates_uniqueness_of :name, :scope => [:opt] + validates_format_of :name, :with => /^[\w\s\'\-]*$/i OPTIONS = { "IPRI" => :enumeration_issue_priorities, diff --git a/app/models/issue_status.rb b/app/models/issue_status.rb index c8a40d330..b821df258 100644 --- a/app/models/issue_status.rb +++ b/app/models/issue_status.rb @@ -21,6 +21,7 @@ class IssueStatus < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name + validates_format_of :name, :with => /^[\w\s\'\-]*$/i validates_length_of :html_color, :is => 6 validates_format_of :html_color, :with => /^[a-f0-9]*$/i diff --git a/app/models/project.rb b/app/models/project.rb index 83197dfde..e8493cb3b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -31,6 +31,7 @@ class Project < ActiveRecord::Base validates_presence_of :name, :description validates_uniqueness_of :name validates_associated :custom_values, :on => :update + validates_format_of :name, :with => /^[\w\s\'\-]*$/i # returns 5 last created projects def self.latest diff --git a/app/models/role.rb b/app/models/role.rb index 6908095e9..4761b75ad 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -23,6 +23,7 @@ class Role < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name + validates_format_of :name, :with => /^[\w\s\'\-]*$/i private def check_integrity diff --git a/app/models/tracker.rb b/app/models/tracker.rb index a4376a351..041525f0f 100644 --- a/app/models/tracker.rb +++ b/app/models/tracker.rb @@ -23,7 +23,8 @@ class Tracker < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name - + validates_format_of :name, :with => /^[\w\s\'\-]*$/i + private def check_integrity raise "Can't delete tracker" if Issue.find(:first, :conditions => ["tracker_id=?", self.id]) diff --git a/app/models/user.rb b/app/models/user.rb index a82c98a88..0287006c6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -32,7 +32,8 @@ class User < ActiveRecord::Base validates_presence_of :login, :firstname, :lastname, :mail validates_uniqueness_of :login, :mail # Login must contain lettres, numbers, underscores only - validates_format_of :login, :with => /^[a-z0-9_]+$/i + validates_format_of :firstname, :lastname, :with => /^[\w\s\'\-]*$/i + validates_format_of :login, :with => /^[a-z0-9_\-@\.]+$/i validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i # Password length between 4 and 12 validates_length_of :password, :in => 4..12, :allow_nil => true diff --git a/app/views/admin/projects.rhtml b/app/views/admin/projects.rhtml index 0772c4e8b..bcf7cba43 100644 --- a/app/views/admin/projects.rhtml +++ b/app/views/admin/projects.rhtml @@ -17,7 +17,7 @@ <% for project in @projects %>
<%= link_to h(document.title), :controller => 'documents', :action => 'show', :id => document %>
+<% unless document.description.empty? %><%=h truncate document.description, 250 %>
<% end %>
+<%= format_time(document.created_on) %>
<%= issue.project.name %> - <%= issue.tracker.name %>
<%= issue.status.name %> - <%= format_time(issue.updated_on) %>
<%= link_to issue.subject, :controller => 'issues', :action => 'show', :id => issue %>
+<%= link_to h(issue.subject), :controller => 'issues', :action => 'show', :id => issue %>
<%=l(:field_assigned_to)%> : | <%= @issue.assigned_to ? @issue.assigned_to.name : "-" %> | -<%=l(:field_category)%> : | <%= @issue.category ? @issue.category.name : "-" %> | +<%=l(:field_category)%> : | <%=h @issue.category ? @issue.category.name : "-" %> | ||||||
<%=l(:field_author)%> : | <%= link_to_user @issue.author %> | @@ -29,7 +29,7 @@||||||||||
<%= custom_value.custom_field.name %> : | <%= show_value custom_value %> | +<%= custom_value.custom_field.name %> : | <%=h show_value custom_value %> | <% n = n + 1 if (n > 1) n = 0 %> diff --git a/app/views/my/blocks/_calendar.rhtml b/app/views/my/blocks/_calendar.rhtml index 2d7930f52..fd221bcb4 100644 --- a/app/views/my/blocks/_calendar.rhtml +++ b/app/views/my/blocks/_calendar.rhtml @@ -34,7 +34,7 @@ while day <= @date_to elsif day == i.due_date image_tag('arrow_to') end %> - <%= link_to "#{i.tracker.name} ##{i.id}", :controller => 'issues', :action => 'show', :id => i %>: <%= i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %>||||||||
<%= link_to project.name, :action => 'show', :id => project %> - | <%= project.description %> + | <%=h project.description %> | <%= format_date(project.created_on) %> | <%= link_to issue.long_id, :controller => 'issues', :action => 'show', :id => issue %> | <%= issue.status.name %> | <%= issue.tracker.name %> | -<%= link_to issue.subject, :controller => 'issues', :action => 'show', :id => issue %> | +<%= link_to h(issue.subject), :controller => 'issues', :action => 'show', :id => issue %> | <%= issue.author.display_name %> | <%= format_time(issue.created_on) %> | <%= format_time(issue.updated_on) %> | diff --git a/app/views/projects/list_news.rhtml b/app/views/projects/list_news.rhtml index 1427c07be..8d8f99668 100644 --- a/app/views/projects/list_news.rhtml +++ b/app/views/projects/list_news.rhtml @@ -5,16 +5,5 @@