Index: app/models/mail_handler.rb =================================================================== --- app/models/mail_handler.rb (revision 17991) +++ app/models/mail_handler.rb (working copy) @@ -43,10 +43,8 @@ options[:no_notification] = (options[:no_notification].to_s == '1') options[:no_permission_check] = (options[:no_permission_check].to_s == '1') - raw_mail.force_encoding('ASCII-8BIT') - ActiveSupport::Notifications.instrument("receive.action_mailer") do |payload| - mail = Mail.new(raw_mail) + mail = Mail.new(raw_mail.b) set_payload_for_mail(payload, mail) new.receive(mail, options) end Index: lib/redmine/codeset_util.rb =================================================================== --- lib/redmine/codeset_util.rb (revision 17991) +++ lib/redmine/codeset_util.rb (working copy) @@ -16,8 +16,7 @@ def self.to_utf8(str, encoding) return if str.nil? - str = str.dup - str.force_encoding("ASCII-8BIT") + str = str.b if str.empty? str.force_encoding("UTF-8") return str @@ -41,8 +40,7 @@ def self.to_utf8_by_setting_internal(str) return if str.nil? - str = str.dup - str.force_encoding('ASCII-8BIT') + str = str.b return str if str.empty? return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii str.force_encoding('UTF-8') Index: lib/redmine/export/pdf.rb =================================================================== --- lib/redmine/export/pdf.rb (revision 17991) +++ lib/redmine/export/pdf.rb (working copy) @@ -134,9 +134,7 @@ class RDMPdfEncoding def self.rdm_from_utf8(txt, encoding) txt ||= '' - txt = Redmine::CodesetUtil.from_utf8(txt, encoding) - txt.force_encoding('ASCII-8BIT') - txt + Redmine::CodesetUtil.from_utf8(txt, encoding).b end def self.attach(attachments, filename, encoding) Index: lib/redmine/scm/adapters/bazaar_adapter.rb =================================================================== --- lib/redmine/scm/adapters/bazaar_adapter.rb (revision 17991) +++ lib/redmine/scm/adapters/bazaar_adapter.rb (working copy) @@ -45,7 +45,7 @@ end def scm_command_version - scm_version = scm_version_from_command_line.dup.force_encoding('ASCII-8BIT') + scm_version = scm_version_from_command_line.b if m = scm_version.match(%r{\A(.*?)((\d+\.)+\d+)}) m[2].scan(%r{\d+}).collect(&:to_i) end @@ -98,8 +98,7 @@ scm_cmd(*cmd_args) do |io| prefix_utf8 = "#{url}/#{path}".tr('\\', '/') logger.debug "PREFIX: #{prefix_utf8}" - prefix = scm_iconv(@path_encoding, 'UTF-8', prefix_utf8) - prefix.force_encoding('ASCII-8BIT') + prefix = scm_iconv(@path_encoding, 'UTF-8', prefix_utf8).b re = %r{^V\s+(#{Regexp.escape(prefix)})?(\/?)([^\/]+)(\/?)\s+(\S+)\r?$} io.each_line do |line| next unless line =~ re Index: lib/redmine/scm/adapters/cvs_adapter.rb =================================================================== --- lib/redmine/scm/adapters/cvs_adapter.rb (revision 17991) +++ lib/redmine/scm/adapters/cvs_adapter.rb (working copy) @@ -45,7 +45,7 @@ end def scm_command_version - scm_version = scm_version_from_command_line.dup.force_encoding('ASCII-8BIT') + scm_version = scm_version_from_command_line.b if m = scm_version.match(%r{\A(.*?)((\d+\.)+\d+)}m) m[2].scan(%r{\d+}).collect(&:to_i) end @@ -93,7 +93,7 @@ def entries(path=nil, identifier=nil, options={}) logger.debug " entries '#{path}' with identifier '#{identifier}'" path_locale = scm_iconv(@path_encoding, 'UTF-8', path) - path_locale = path_locale.dup.force_encoding("ASCII-8BIT") + path_locale = path_locale.b entries = Entries.new cmd_args = %w|-q rls -e| cmd_args << "-D" << time_to_cvstime_rlog(identifier) if identifier Index: lib/redmine/scm/adapters/git_adapter.rb =================================================================== --- lib/redmine/scm/adapters/git_adapter.rb (revision 17991) +++ lib/redmine/scm/adapters/git_adapter.rb (working copy) @@ -49,7 +49,7 @@ end def scm_command_version - scm_version = scm_version_from_command_line.dup.force_encoding('ASCII-8BIT') + scm_version = scm_version_from_command_line.b if m = scm_version.match(%r{\A(.*?)((\d+\.)+\d+)}) m[2].scan(%r{\d+}).collect(&:to_i) end Index: lib/redmine/scm/adapters/mercurial_adapter.rb =================================================================== --- lib/redmine/scm/adapters/mercurial_adapter.rb (revision 17991) +++ lib/redmine/scm/adapters/mercurial_adapter.rb (working copy) @@ -58,7 +58,7 @@ # The hg version is expressed either as a # release number (eg 0.9.5 or 1.0) or as a revision # id composed of 12 hexa characters. - theversion = hgversion_from_command_line.dup.force_encoding('ASCII-8BIT') + theversion = hgversion_from_command_line.b if m = theversion.match(%r{\A(.*?)((\d+\.)+\d+)}) m[2].scan(%r{\d+}).collect(&:to_i) end @@ -270,8 +270,7 @@ blame = Annotate.new hg 'rhannotate', '-ncu', "-r#{CGI.escape(hgrev(identifier))}", '--', hgtarget(p) do |io| io.each_line do |line| - line.force_encoding('ASCII-8BIT') - next unless line =~ %r{^([^:]+)\s(\d+)\s([0-9a-f]+):\s(.*)$} + next unless line.b =~ %r{^([^:]+)\s(\d+)\s([0-9a-f]+):\s(.*)$} r = Revision.new(:author => $1.strip, :revision => $2, :scmid => $3, :identifier => $3) blame.add_line($4.rstrip, r) Index: lib/redmine/scm/adapters/subversion_adapter.rb =================================================================== --- lib/redmine/scm/adapters/subversion_adapter.rb (revision 17991) +++ lib/redmine/scm/adapters/subversion_adapter.rb (working copy) @@ -48,7 +48,7 @@ end def svn_binary_version - scm_version = scm_version_from_command_line.dup.force_encoding('ASCII-8BIT') + scm_version = scm_version_from_command_line.b if m = scm_version.match(%r{\A(.*?)((\d+\.)+\d+)}) m[2].scan(%r{\d+}).collect(&:to_i) end