From 20f6dc346a2ea8497a17e3c9df6362073f86aa93 Mon Sep 17 00:00:00 2001 From: Alexey I. Froloff Date: Sun, 29 Nov 2009 19:12:22 +0300 Subject: [PATCH] Ruby 1.9.1p343 breaks \w and \s, replace with [:word:] and [:space:] --- app/models/custom_field.rb | 2 +- app/models/issue_status.rb | 2 +- app/models/role.rb | 2 +- app/models/tracker.rb | 2 +- app/models/user.rb | 2 +- lib/redcloth3.rb | 2 +- lib/redmine/wiki_formatting/textile/formatter.rb | 2 +- lib/tasks/migrate_from_mantis.rake | 6 +++--- lib/tasks/migrate_from_trac.rake | 4 ++-- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index 5160fcf..d90a715 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -32,7 +32,7 @@ class CustomField < ActiveRecord::Base validates_presence_of :name, :field_format validates_uniqueness_of :name, :scope => :type validates_length_of :name, :maximum => 30 - validates_format_of :name, :with => /^[\w\s\.\'\-]*$/i + validates_format_of :name, :with => /^[[:word:][:space:]\.\'\-]*$/i validates_inclusion_of :field_format, :in => FIELD_FORMATS.keys def initialize(attributes = nil) diff --git a/app/models/issue_status.rb b/app/models/issue_status.rb index ca33d37..ef4d08a 100644 --- a/app/models/issue_status.rb +++ b/app/models/issue_status.rb @@ -23,7 +23,7 @@ class IssueStatus < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name validates_length_of :name, :maximum => 30 - validates_format_of :name, :with => /^[\w\s\'\-]*$/i + validates_format_of :name, :with => /^[[:word:][:space:]\'\-]*$/i def after_save IssueStatus.update_all("is_default=#{connection.quoted_false}", ['id <> ?', id]) if self.is_default? diff --git a/app/models/role.rb b/app/models/role.rb index db58257..8877007 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -49,7 +49,7 @@ class Role < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name validates_length_of :name, :maximum => 30 - validates_format_of :name, :with => /^[\w\s\'\-]*$/i + validates_format_of :name, :with => /^[[:word:][:space:]\'\-]*$/i def permissions read_attribute(:permissions) || [] diff --git a/app/models/tracker.rb b/app/models/tracker.rb index 7c5bae2..b9951b2 100644 --- a/app/models/tracker.rb +++ b/app/models/tracker.rb @@ -37,7 +37,7 @@ class Tracker < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name validates_length_of :name, :maximum => 30 - validates_format_of :name, :with => /^[\w\s\'\-]*$/i + validates_format_of :name, :with => /^[[:word:][:space:]\'\-]*$/i def to_s; name end diff --git a/app/models/user.rb b/app/models/user.rb index e9c58bc..2898036 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -57,7 +57,7 @@ class User < Principal # Login must contain lettres, numbers, underscores only validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i validates_length_of :login, :maximum => 30 - validates_format_of :firstname, :lastname, :with => /^[\w\s\'\-\.]*$/i + validates_format_of :firstname, :lastname, :with => /^[[:word:][:space:]\'\-\.]*$/i validates_length_of :firstname, :lastname, :maximum => 30 validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_nil => true validates_length_of :mail, :maximum => 60, :allow_nil => true diff --git a/lib/redcloth3.rb b/lib/redcloth3.rb index 0adf207..9b63aae 100644 --- a/lib/redcloth3.rb +++ b/lib/redcloth3.rb @@ -352,7 +352,7 @@ class RedCloth3 < String PUNCT = Regexp::quote( '!"#$%&\'*+,-./:;=?@\\^_`|~' ) PUNCT_NOQ = Regexp::quote( '!"#$&\',./:;=?@\\`|' ) PUNCT_Q = Regexp::quote( '*-_+^~%' ) - HYPERLINK = '(\S+?)([^\w\s/;=\?]*?)(?=\s|<|$)' + HYPERLINK = '(\S+?)([^[:word:][:space:]/;=\?]*?)(?=\s|<|$)' # Text markup tags, don't conflict with block tags SIMPLE_HTML_TAGS = [ diff --git a/lib/redmine/wiki_formatting/textile/formatter.rb b/lib/redmine/wiki_formatting/textile/formatter.rb index 7e20c7b..2dcce26 100644 --- a/lib/redmine/wiki_formatting/textile/formatter.rb +++ b/lib/redmine/wiki_formatting/textile/formatter.rb @@ -71,7 +71,7 @@ module Redmine toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1' # replaces non word caracters by dashes - anchor = toc_item.gsub(%r{[^\w\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-') + anchor = toc_item.gsub(%r{[^[:word:][:space:]\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-') unless anchor.blank? if tag =~ /^h(\d)$/ diff --git a/lib/tasks/migrate_from_mantis.rake b/lib/tasks/migrate_from_mantis.rake index a7582a3..5ffe716 100644 --- a/lib/tasks/migrate_from_mantis.rake +++ b/lib/tasks/migrate_from_mantis.rake @@ -88,13 +88,13 @@ task :migrate_from_mantis => :environment do def firstname @firstname = realname.blank? ? username : realname.split.first[0..29] - @firstname.gsub!(/[^\w\s\'\-]/i, '') + @firstname.gsub!(/[^[:word:][:space:]\'\-]/i, '') @firstname end def lastname @lastname = realname.blank? ? '-' : realname.split[1..-1].join(' ')[0..29] - @lastname.gsub!(/[^\w\s\'\-]/i, '') + @lastname.gsub!(/[^[:word:][:space:]\'\-]/i, '') @lastname = '-' if @lastname.blank? @lastname end @@ -228,7 +228,7 @@ task :migrate_from_mantis => :environment do end def name - read_attribute(:name)[0..29].gsub(/[^\w\s\'\-]/, '-') + read_attribute(:name)[0..29].gsub(/[^[:word:][:space:]\'\-]/, '-') end end diff --git a/lib/tasks/migrate_from_trac.rake b/lib/tasks/migrate_from_trac.rake index 1902af8..ea8add8 100644 --- a/lib/tasks/migrate_from_trac.rake +++ b/lib/tasks/migrate_from_trac.rake @@ -246,8 +246,8 @@ namespace :redmine do ln = ($2 || '-').strip u = User.new :mail => mail.gsub(/[^-@a-z0-9\.]/i, '-'), - :firstname => fn[0, limit_for(User, 'firstname')].gsub(/[^\w\s\'\-]/i, '-'), - :lastname => ln[0, limit_for(User, 'lastname')].gsub(/[^\w\s\'\-]/i, '-') + :firstname => fn[0, limit_for(User, 'firstname')].gsub(/[^[:word:][:space:]\'\-]/i, '-'), + :lastname => ln[0, limit_for(User, 'lastname')].gsub(/[^[:word:][:space:]\'\-]/i, '-') u.login = username[0,limit_for(User, 'login')].gsub(/[^a-z0-9_\-@\.]/i, '-') u.password = 'trac' -- 1.6.5.3