From 8d7de50ca8f7b440cb67c8161122d20909a3a93f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 22 Apr 2007 09:50:16 +0000 Subject: [PATCH] Fixed 10211 Wiki names can't have periods in them. Same validations as WikiPage model now applied to wiki start page. git-svn-id: http://redmine.rubyforge.org/svn/trunk@463 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/wiki.rb | 3 ++- app/models/wiki_page.rb | 2 +- app/views/projects/_form.rhtml | 2 +- lang/de.yml | 1 + lang/en.yml | 1 + lang/es.yml | 1 + lang/fr.yml | 1 + lang/it.yml | 1 + lang/ja.yml | 1 + lang/pt.yml | 1 + lang/zh.yml | 1 + 11 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/models/wiki.rb b/app/models/wiki.rb index e362273ae..8233c3d48 100644 --- a/app/models/wiki.rb +++ b/app/models/wiki.rb @@ -20,6 +20,7 @@ class Wiki < ActiveRecord::Base has_many :pages, :class_name => 'WikiPage', :dependent => :destroy validates_presence_of :start_page + validates_format_of :start_page, :with => /^[^,\.\/\?\;\|]*$/ # find the page with the given title # if page doesn't exist, return a new page @@ -36,7 +37,7 @@ class Wiki < ActiveRecord::Base # turn a string into a valid page title def self.titleize(title) # replace spaces with _ and remove unwanted caracters - title = title.gsub(/\s+/, '_').delete(',;|') if title + title = title.gsub(/\s+/, '_').delete(',./?;|') if title # upcase the first letter title = title[0..0].upcase + title[1..-1] if title title diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index f2ea8fd59..b7964a119 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -20,7 +20,7 @@ class WikiPage < ActiveRecord::Base has_one :content, :class_name => 'WikiContent', :foreign_key => 'page_id', :dependent => :destroy validates_presence_of :title - validates_format_of :title, :with => /^[^,\s]*$/ + validates_format_of :title, :with => /^[^,\.\/\?\;\|\s]*$/ validates_uniqueness_of :title, :scope => :wiki_id, :case_sensitive => false validates_associated :content diff --git a/app/views/projects/_form.rhtml b/app/views/projects/_form.rhtml index 03a757d70..5f253d401 100644 --- a/app/views/projects/_form.rhtml +++ b/app/views/projects/_form.rhtml @@ -44,7 +44,7 @@ <%= hidden_field_tag "wiki_enabled", 0 %>
<% fields_for :wiki, @project.wiki, { :builder => TabularFormBuilder, :lang => current_language} do |wiki| %> -

<%= wiki.text_field :start_page, :size => 60, :required => true %>

+

<%= wiki.text_field :start_page, :size => 60, :required => true %>
<%= l(:text_unallowed_characters) %>: , . / ? ; |

<% # content_tag("div", "", :id => "wiki_start_page_auto_complete", :class => "auto_complete") + # auto_complete_field("wiki_start_page", { :url => { :controller => 'wiki', :action => 'auto_complete_for_wiki_page', :id => @project } }) %> diff --git a/lang/de.yml b/lang/de.yml index 9ef10cae5..f8b7bc0da 100644 --- a/lang/de.yml +++ b/lang/de.yml @@ -407,6 +407,7 @@ text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allo text_caracters_maximum: %d characters maximum. text_length_between: Length between %d and %d characters. text_tracker_no_workflow: No workflow defined for this tracker +text_unallowed_characters: Unallowed characters default_role_manager: Manager default_role_developper: Developer diff --git a/lang/en.yml b/lang/en.yml index 690706793..d26bb8a75 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -407,6 +407,7 @@ text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allo text_caracters_maximum: %d characters maximum. text_length_between: Length between %d and %d characters. text_tracker_no_workflow: No workflow defined for this tracker +text_unallowed_characters: Unallowed characters default_role_manager: Manager default_role_developper: Developer diff --git a/lang/es.yml b/lang/es.yml index 026f5ddb8..0e31980f2 100644 --- a/lang/es.yml +++ b/lang/es.yml @@ -407,6 +407,7 @@ text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allo text_caracters_maximum: %d characters maximum. text_length_between: Length between %d and %d characters. text_tracker_no_workflow: No workflow defined for this tracker +text_unallowed_characters: Unallowed characters default_role_manager: Manager default_role_developper: Desarrollador diff --git a/lang/fr.yml b/lang/fr.yml index 45d24caf1..42b46eeba 100644 --- a/lang/fr.yml +++ b/lang/fr.yml @@ -407,6 +407,7 @@ text_project_identifier_info: 'Lettres minuscules (a-z), chiffres et tirets auto text_caracters_maximum: %d caractères maximum. text_length_between: Longueur comprise entre %d et %d caractères. text_tracker_no_workflow: Aucun worflow n'est défini pour ce tracker +text_unallowed_characters: Caractères non autorisés default_role_manager: Manager default_role_developper: Développeur diff --git a/lang/it.yml b/lang/it.yml index 0bd9c1b10..49c04a6ac 100644 --- a/lang/it.yml +++ b/lang/it.yml @@ -407,6 +407,7 @@ text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allo text_caracters_maximum: %d characters maximum. text_length_between: Length between %d and %d characters. text_tracker_no_workflow: No workflow defined for this tracker +text_unallowed_characters: Unallowed characters default_role_manager: Manager default_role_developper: Sviluppatore diff --git a/lang/ja.yml b/lang/ja.yml index 235bf1be1..66accb7f9 100644 --- a/lang/ja.yml +++ b/lang/ja.yml @@ -408,6 +408,7 @@ text_project_identifier_info: '英小文字(a-z)と数字とダッシュ(-)が text_caracters_maximum: 最大 %d 文字です。 text_length_between: 長さは %d から %d 文字までです。 text_tracker_no_workflow: このトラッカーにワークフローが定義されていません +text_unallowed_characters: Unallowed characters default_role_manager: 管理者 default_role_developper: 開発者 diff --git a/lang/pt.yml b/lang/pt.yml index e107c2b39..0bb4156a5 100644 --- a/lang/pt.yml +++ b/lang/pt.yml @@ -407,6 +407,7 @@ text_project_identifier_info: 'Letras minusculas (a-z), numeros e tracos permiti text_caracters_maximum: %d maximo de caracteres text_length_between: Tamanho entre %d e %d caracteres. text_tracker_no_workflow: Sem workflow definido para este tipo. +text_unallowed_characters: Unallowed characters default_role_manager: Analista de Negocio ou Gerente de Projeto default_role_developper: Desenvolvedor diff --git a/lang/zh.yml b/lang/zh.yml index 03ff2bc63..493838dc3 100644 --- a/lang/zh.yml +++ b/lang/zh.yml @@ -410,6 +410,7 @@ text_project_identifier_info: 'Lower case letters (a-z), numbers and dashes allo text_caracters_maximum: %d characters maximum. text_length_between: Length between %d and %d characters. text_tracker_no_workflow: No workflow defined for this tracker +text_unallowed_characters: Unallowed characters default_role_manager: 管理员 default_role_developper: 开发人员