Project

General

Profile

Actions

Defect #31052

closed

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

Added by Mizuki ISHIKAWA about 5 years ago. Updated about 5 years ago.

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

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

When I access the URL below, the error "can't modify frozen String" is returned.
http://localhost:3000/projects/ecookbook/repository/10/diff?format=diff&rev=11&rev_to=10

Log:

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 literalsClosedGo MAEDA

Actions
Actions #1

Updated by Mizuki ISHIKAWA about 5 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',

Actions #2

Updated by Go MAEDA about 5 years ago

Actions #3

Updated by Go MAEDA about 5 years ago

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

Committed.
Thank you for catching and fixing the error.

Actions

Also available in: Atom PDF