Defect #31052

Download unified diff throws "can't modify frozen String" error.

Added by Mizuki ISHIKAWA over 3 years ago. Updated over 3 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:


Target version:-
Resolution:Fixed Affected version:


When I access the URL below, the error "can't modify frozen String" is returned.


Started GET "/projects/ecookbook/repository/10/diff?format=diff&rev=11&rev_to=10" for ::1 at 2019-03-19 11:25:08 +0900
Processing by RepositoriesController#diff as 
  Parameters: {"rev"=>"11", "rev_to"=>"10", "id"=>"ecookbook", "repository_id"=>"10"}
Completed 500 Internal Server Error in 347ms (ActiveRecord: 255.1ms)

RuntimeError - can't modify frozen String:
  app/controllers/repositories_controller.rb:243:in `diff'
  lib/redmine/sudo_mode.rb:65:in `sudo_mode'

This occurred in trunk(r17989).
I think this is related to #26561.

Related issues

Related to Redmine - Feature #26561: Enable frozen string literals Closed

Associated revisions

Revision 17990
Added by Go MAEDA over 3 years ago

Fix FrozenError in RepositoriesController#diff (#31052, #26561).

Patch by Mizuki ISHIKAWA.


#1 Updated by Mizuki ISHIKAWA over 3 years ago

I confirmed that changing it as below solves the problem.

diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index e0af12a3ca..ff950799bd 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -239,7 +239,7 @@ class RepositoriesController < ApplicationController
     if params[:format] == 'diff'
       @diff = @repository.diff(@path, @rev, @rev_to)
       (show_error_not_found; return) unless @diff
-      filename = "changeset_r#{@rev}" 
+      filename = +"changeset_r#{@rev}" 
       filename << "_r#{@rev_to}" if @rev_to
       send_data @diff.join, :filename => "#{filename}.diff",
                             :type => 'text/x-patch',

#2 Updated by Go MAEDA over 3 years ago

#3 Updated by Go MAEDA over 3 years ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Thank you for catching and fixing the error.

Also available in: Atom PDF