Project

General

Profile

Actions

Defect #17235

closed

use test_email report can't modify frozen String

Added by hongbo yang almost 10 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Email notifications
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

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'))

Actions #1

Updated by Toshi MARUYAMA almost 10 years ago

  • Target version set to 2.4.6
Actions #2

Updated by Toshi MARUYAMA almost 10 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')

Actions #3

Updated by hongbo yang almost 10 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 :-)

Actions #4

Updated by Toshi MARUYAMA almost 10 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.

Actions

Also available in: Atom PDF