diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2015-08-12 12:54:06 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2015-08-12 12:54:06 +0000 |
commit | 918a412fd4c807eacfb9986cd13d76b5e7978077 (patch) | |
tree | 10bd8e77921dd6aec767867e3bd5c3eb1bd41328 /app | |
parent | 039c333cec7588ec186b8b15ad570d4c62ce3d95 (diff) | |
download | redmine-918a412fd4c807eacfb9986cd13d76b5e7978077.tar.gz redmine-918a412fd4c807eacfb9986cd13d76b5e7978077.zip |
use String#casecmp for case insensitive comparison (#20369)
Contributed by Go MAEDA.
git-svn-id: http://svn.redmine.org/redmine/trunk@14484 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/account_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 2 | ||||
-rw-r--r-- | app/models/custom_field.rb | 2 | ||||
-rw-r--r-- | app/models/mail_handler.rb | 13 | ||||
-rw-r--r-- | app/models/principal.rb | 2 | ||||
-rw-r--r-- | app/models/project.rb | 2 |
6 files changed, 12 insertions, 11 deletions
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 57e08c348..798ccfb92 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -102,7 +102,7 @@ class AccountController < ApplicationController token = Token.new(:user => user, :action => "recovery") if token.save # Don't use the param to send the email - recipent = user.mails.detect {|e| e.downcase == email.downcase} || user.mail + recipent = user.mails.detect {|e| email.casecmp(e) == 0} || user.mail Mailer.lost_password(token, recipent).deliver flash[:notice] = l(:notice_account_lost_email_sent) redirect_to signin_path diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0d3f520a7..ce6142050 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -609,7 +609,7 @@ module ApplicationHelper parsed << text if tag if closing - if tags.last == tag.downcase + if tags.last.casecmp(tag) == 0 tags.pop end else diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index 3fbb1edc2..71a32d138 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -144,7 +144,7 @@ class CustomField < ActiveRecord::Base possible_values_options = possible_values_options(customized) if possible_values_options.present? keyword = keyword.to_s.downcase - if v = possible_values_options.detect {|text, id| text.downcase == keyword} + if v = possible_values_options.detect {|text, id| keyword.casecmp(text) == 0} if v.is_a?(Array) v.last else diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb index 0696216b1..269b0c4fa 100644 --- a/app/models/mail_handler.rb +++ b/app/models/mail_handler.rb @@ -92,7 +92,7 @@ class MailHandler < ActionMailer::Base @handler_options = options sender_email = email.from.to_a.first.to_s.strip # Ignore emails received from the application emission address to avoid hell cycles - if sender_email.downcase == Setting.mail_from.to_s.strip.downcase + if sender_email.casecmp(Setting.mail_from.to_s.strip) == 0 if logger logger.info "MailHandler: ignoring email from Redmine emission address [#{sender_email}]" end @@ -547,18 +547,19 @@ class MailHandler < ActionMailer::Base assignable = issue.assignable_users assignee = nil assignee ||= assignable.detect {|a| - a.mail.to_s.downcase == keyword || - a.login.to_s.downcase == keyword + keyword.casecmp(a.mail.to_s) == 0 || + keyword.casecmp(a.login.to_s) == 0 } if assignee.nil? && keyword.match(/ /) firstname, lastname = *(keyword.split) # "First Last Throwaway" assignee ||= assignable.detect {|a| - a.is_a?(User) && a.firstname.to_s.downcase == firstname && - a.lastname.to_s.downcase == lastname + a.is_a?(User) && + firstname.casecmp(a.firstname.to_s) == 0 && + lastname.casecmp(a.lastname.to_s) == 0 } end if assignee.nil? - assignee ||= assignable.detect {|a| a.name.downcase == keyword} + assignee ||= assignable.detect {|a| keyword.casecmp(a.name) == 0} end assignee end diff --git a/app/models/principal.rb b/app/models/principal.rb index fcc56b432..15ab02147 100644 --- a/app/models/principal.rb +++ b/app/models/principal.rb @@ -130,7 +130,7 @@ class Principal < ActiveRecord::Base if principal.nil? -1 elsif self.class.name == principal.class.name - self.to_s.downcase <=> principal.to_s.downcase + self.to_s.casecmp(principal.to_s) else # groups after users principal.class.name <=> self.class.name diff --git a/app/models/project.rb b/app/models/project.rb index 4a54b2210..81bb17991 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -531,7 +531,7 @@ class Project < ActiveRecord::Base end def <=>(project) - name.downcase <=> project.name.downcase + name.casecmp(project.name) end def to_s |