Project

General

Profile

Defect #10673 » allow-dots-and-commas-in-wiki-page-names.patch

Allow dots and commas in wiki page names - Luc Luc, 2025-05-12 14:24

View differences:

app/models/wiki.rb
26 26
  acts_as_watchable
27 27

  
28 28
  validates_presence_of :start_page
29
  validates_format_of :start_page, :with => /\A[^,\.\/\?\;\|\:]*\z/
29
  validates_format_of :start_page, :with => /\A[^\/\?\;\|\:]*\z/
30 30
  validates_length_of :start_page, maximum: 255
31 31

  
32 32
  before_destroy :delete_redirects
......
104 104
  # turn a string into a valid page title
105 105
  def self.titleize(title)
106 106
    # replace spaces with _ and remove unwanted caracters
107
    title = title.gsub(/\s+/, '_').delete(',./?;|:') if title
107
    title = title.gsub(/\s+/, '_').delete('/?;|:') if title
108 108
    # upcase the first letter
109 109
    title = (title.slice(0..0).upcase + (title.slice(1..-1) || '')) if title
110 110
    title
app/models/wiki_page.rb
52 52
  attr_writer   :deleted_attachment_ids
53 53

  
54 54
  validates_presence_of :title
55
  validates_format_of :title, :with => /\A[^,\.\/\?\;\|\s]*\z/
55
  validates_format_of :title, :with => /\A[^\/\?\;\|\s]*\z/
56 56
  validates_uniqueness_of :title, :scope => :wiki_id, :case_sensitive => false
57 57
  validates_length_of :title, maximum: 255
58 58
  validates_associated :content
app/views/wiki/_new_modal.html.erb
10 10
  <div class="box tabular">
11 11
    <p>
12 12
      <%= f.text_field :title, :name => 'title', :size => 60, :required => true %>
13
      <em class="info"><%= l(:text_unallowed_characters) %>: , . / ? ; : |</em>
13
      <em class="info"><%= l(:text_unallowed_characters) %>: / ? ; : |</em>
14 14
    </p>
15 15
    <p>
16 16
    <% if params[:parent].present? %>
app/views/wiki/new.html.erb
8 8
  <div class="box tabular">
9 9
    <p>
10 10
      <%= f.text_field :title, :name => 'title', :size => 60, :required => true %>
11
      <em class="info"><%= l(:text_unallowed_characters) %>: , . / ? ; : |</em>
11
      <em class="info"><%= l(:text_unallowed_characters) %>: / ? ; : |</em>
12 12
    </p>
13 13
  </div>
14 14

  
config/routes.rb
192 192
    end
193 193

  
194 194
    match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get
195
    resources :wiki, :except => [:index, :create], :as => 'wiki_page' do
196
      member do
197
        get 'rename'
198
        post 'rename'
199
        get 'history'
200
        get 'diff'
201
        match 'preview', :via => [:post, :put, :patch]
202
        post 'protect'
203
        post 'add_attachment'
204
      end
205
      collection do
206
        get 'export'
207
        get 'date_index'
208
        post 'new'
195
    constraints(id: /[^\/]+/) do
196
      resources :wiki, :except => [:index, :create], :as => 'wiki_page' do
197
        member do
198
          get 'rename'
199
          post 'rename'
200
          get 'history'
201
          get 'diff'
202
          match 'preview', :via => [:post, :put, :patch]
203
          post 'protect'
204
          post 'add_attachment'
205
        end
206
        collection do
207
          get 'export'
208
          get 'date_index'
209
          post 'new'
210
        end
209 211
      end
210
    end
211
    match 'wiki', :controller => 'wiki', :action => 'show', :via => :get
212
    get 'wiki/:id/:version', :to => 'wiki#show', :constraints => {:version => /\d+/}
213
    delete 'wiki/:id/:version', :to => 'wiki#destroy_version'
214
    get 'wiki/:id/:version/annotate', :to => 'wiki#annotate'
215
    get 'wiki/:id/:version/diff', :to => 'wiki#diff'
212
      match 'wiki', :controller => 'wiki', :action => 'show', :via => :get
213
      get 'wiki/:id/:version', :to => 'wiki#show', :constraints => {:version => /\d+/}
214
      delete 'wiki/:id/:version', :to => 'wiki#destroy_version'
215
      get 'wiki/:id/:version/annotate', :to => 'wiki#annotate'
216
      get 'wiki/:id/:version/diff', :to => 'wiki#diff'
217
   end
216 218
  end
217 219

  
218 220
  resources :issues do
(4-4/4)