Project

General

Profile

Defect #10673 » commas.patch

Alexander Oryol, 2012-04-16 17:08

View differences:

app/models/wiki.rb
24 24
  acts_as_watchable
25 25

  
26 26
  validates_presence_of :start_page
27
  validates_format_of :start_page, :with => /^[^,\.\/\?\;\|\:]*$/
27
  validates_format_of :start_page, :with => /^[^\.\/\;\|\:]*$/
28 28

  
29 29
  safe_attributes 'start_page'
30 30

  
......
89 89
  # turn a string into a valid page title
90 90
  def self.titleize(title)
91 91
    # replace spaces with _ and remove unwanted caracters
92
    title = title.gsub(/\s+/, '_').delete(',./?;|:') if title
92
    title = title.gsub(/\s+/, '_').delete('./?;|:') if title
93 93
    # upcase the first letter
94 94
    title = (title.slice(0..0).upcase + (title.slice(1..-1) || '')) if title
95 95
    title
app/models/wiki_page.rb
40 40
  attr_accessor :redirect_existing_links
41 41

  
42 42
  validates_presence_of :title
43
  validates_format_of :title, :with => /^[^,\.\/\?\;\|\s]*$/
43
  validates_format_of :title, :with => /^[^\.\/\?\;\|\s]*$/
44 44
  validates_uniqueness_of :title, :scope => :wiki_id, :case_sensitive => false
45 45
  validates_associated :content
46 46

  
app/views/projects/settings/_wiki.html.erb
5 5

  
6 6
<div class="box tabular">
7 7
<p><%= f.text_field :start_page, :size => 60, :required => true %>
8
<em class="info"><%= l(:text_unallowed_characters) %>: , . / ? ; : |</em></p>
8
<em class="info"><%= l(:text_unallowed_characters) %>: . / ? ; : |</em></p>
9 9
</div>
10 10

  
11 11
<div class="contextual">
config/routes.rb
20 20
              :conditions => {:method => :get}
21 21

  
22 22
  map.connect 'projects/:id/wiki', :controller => 'wikis',
23
              :action => 'edit', :conditions => {:method => :post}
23
              :action => 'edit', :conditions => {:method => :post}, :requirements => { :id => /.*/ }
24 24
  map.connect 'projects/:id/wiki/destroy', :controller => 'wikis',
25
              :action => 'destroy', :conditions => {:method => [:get, :post]}
25
              :action => 'destroy', :conditions => {:method => [:get, :post]}, :requirements => { :id => /.*/ }
26 26

  
27 27
  map.with_options :controller => 'messages' do |messages_routes|
28 28
    messages_routes.with_options :conditions => {:method => :get} do |messages_views|
......
179 179

  
180 180
    project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get}
181 181
    project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get}
182
    project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil
183
    project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff'
184
    project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate'
182
    project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil, :requirements => { :id => /.*/ }
183
    project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff', :requirements => { :id => /.*/ }
184
    project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate', :requirements => { :id => /.*/ }
185 185
    project.resources :wiki, :except => [:new, :create], :member => {
186 186
      :rename => [:get, :post],
187 187
      :history => :get,
......
191 191
    }, :collection => {
192 192
      :export => :get,
193 193
      :date_index => :get
194
    }
194
    }, :requirements => { :id => /.*/ }
195 195
  end
196 196

  
197 197
  map.connect 'news', :controller => 'news', :action => 'index'
(2-2/3)