Defect #17235

use test_email report can't modify frozen String

Added by hongbo yang over 3 years ago. Updated over 3 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Email notifications
Target version:2.4.6
Resolution:Fixed Affected version:2.5.1

Description

version:
Environment:
Redmine version 2.5.1.stable
Ruby version 1.9.3-p545 (2014-02-24) [x86_64-linux]
Rails version 3.2.17
Environment production
Database adapter Mysql2
SCM:
Subversion 1.8.8
Git 1.9.0
Filesystem
Redmine plugins:
no plugin installed

call to : http://host/redmine/admin/test_email

exception:
RuntimeError (can't modify frozen String):
lib/redmine/codeset_util.rb:11:in `force_encoding'
lib/redmine/codeset_util.rb:11:in `replace_invalid_utf8'
app/controllers/admin_controller.rb:68:in `rescue in test_email'
app/controllers/admin_controller.rb:64:in `test_email'

fix:
I added str = str.dup @ line 11 in lib/redmine/codeset_util.rb (before str.force_encoding('UTF-8'))

Associated revisions

Revision 13198
Added by Toshi MARUYAMA over 3 years ago

prevent "can't modify frozen String" exception when mail sending error (#17235)

Revision 13200
Added by Toshi MARUYAMA over 3 years ago

Merged r13198 from trunk to 2.5-stable (#17235)

Prevent "can't modify frozen String" exception when mail sending error.

Revision 13202
Added by Toshi MARUYAMA over 3 years ago

Merged r13198 from trunk to 2.4-stable (#17235)

Prevent "can't modify frozen String" exception when mail sending error.

History

#1 Updated by Toshi MARUYAMA over 3 years ago

  • Target version set to 2.4.6

#2 Updated by Toshi MARUYAMA over 3 years ago

Could you try this fix instead of your fix.

diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -65,7 +65,7 @@ class AdminController < ApplicationContr
       @test = Mailer.test_email(User.current).deliver
       flash[:notice] = l(:notice_email_sent, User.current.mail)
     rescue Exception => e
-      flash[:error] = l(:notice_email_error, Redmine::CodesetUtil.replace_invalid_utf8(e.message))
+      flash[:error] = l(:notice_email_error, Redmine::CodesetUtil.replace_invalid_utf8(e.message.dup))
     end
     ActionMailer::Base.raise_delivery_errors = raise_delivery_errors
     redirect_to settings_path(:tab => 'notifications')

#3 Updated by hongbo yang over 3 years ago

Toshi MARUYAMA wrote:

Could you try this fix instead of your fix.

[...]

Great! It works. I'm not a ruby programmer though, but I know it is a better fix :-)

#4 Updated by Toshi MARUYAMA over 3 years ago

  • Status changed from New to Closed
  • Resolution set to Fixed

Committed in trunk r13198, 2.5-stable r13200 and 2.4-stable r13202.

Also available in: Atom PDF