プロジェクト

全般

プロフィール

Vote #73679

完了

Diff - Internal Error

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
SCM_3
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
3
version_id:
71
issue_org_id:
13644
author_id:
67812
assigned_to_id:
0
comments:
13
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
60
ステータス-->[Closed]

説明

Received error 500 attempting to view diff. I attached the files being compared.

An ActionView::Template::Error occurred in repositories#diff:

  undefined method `ord' for nil:NilClass
  lib/redmine/unified_diff.rb:209:in `offsets'

Partial Trace:

  lib/redmine/unified_diff.rb:209:in `offsets'
  lib/redmine/unified_diff.rb:187:in `write_offsets'
  lib/redmine/unified_diff.rb:184:in `times'
  lib/redmine/unified_diff.rb:184:in `write_offsets'
  lib/redmine/unified_diff.rb:163:in `parse_line'
  lib/redmine/unified_diff.rb:85:in `add_line'
  lib/redmine/unified_diff.rb:33:in `initialize'
  lib/redmine/unified_diff.rb:31:in `each'
  lib/redmine/unified_diff.rb:31:in `initialize'
  app/views/common/_diff.html.erb:1:in `new'
  app/views/common/_diff.html.erb:1:in `_app_views_common__diff_html_erb__374540104_111303620'
  actionpack (3.2.13) lib/action_view/template.rb:145:in `send'
  actionpack (3.2.13) lib/action_view/template.rb:145:in `render'

Environment:

  Redmine version                          2.3.0.stable.11692
  Ruby version                             1.8.7 (i686-linux)
  Rails version                            3.2.13
  Environment                              production
  Database adapter                         MySQL

journals

I confirm.

<pre>
Environment:
Redmine version 2.3.0.stable
Ruby version 1.9.3 (i386-mingw32)
Rails version 3.2.13
Environment production
Database adapter Mysql2
Redmine plugins:
clipboard_image_paste 1.5
projects_tree_view 0.0.8
redmine_apijs 4.2.0
redmine_code_review 0.6.1
redmine_didyoumean 1.2.0
redmine_favourite_projects 0.6
redmine_information 1.0.2
redmine_issue_checklist 2.0.5
redmine_local_avatars 0.1.1
redmine_pastebin 0.2.0
redmine_plugin_views_revisions 0.0.1
redmine_theme_changer 0.1.0
redmine_user_issues 0.0.2
redmine_wiki_gchart_formula 0.0.5
redmine_xls_export 0.2.1
redmine_youtube 0.0.1
sidebar_hide 0.0.2
wiking 0.0.3
</pre>
--------------------------------------------------------------------------------
This is a major issue, please fix it ASAP.

The commit that introduced this is r11549 (#12641). A mistake :(
In 'lib/redmine/unified_diff.rb', the following hunks should be fixed:

<pre><code class="diff">
- while line_left[starting].ord.between?(128, 191) && starting > 0
+ while starting > 0 && line_left[starting].ord.between?(128, 191)
...(omitted)...
- while line_left[ending].ord.between?(128, 191) && ending > -1
+ while ending > -1 && line_left[ending].ord.between?(128, 191)
</code></pre>

I've submitted the patch.
--------------------------------------------------------------------------------
It reminds me to #12641 (r11551). I suggested at first a the patch containing the lines with "<code>.ord.between?(128, 191)</code>" but recognized later a much more elegant solution and added a second patch that just sets the encoding. The 2nd patch hasn't been taken. Why not simply setting the encoding?
--------------------------------------------------------------------------------
Filou Centrinov wrote:
> Why not simply setting the encoding?
Because tests fail on Ruby 1.8.7.

--------------------------------------------------------------------------------
I cannot reproduce on ruby 1.8.7 (2012-10-12 patchlevel 371) [x86_64-linux].
<pre><code>
$ irb
1.8.7 :001 > s = "abc"
=> "abc"
1.8.7 :002 > s[-1].ord
=> 99
1.8.7 :003 > s = "日本語"
=> "\346\227\245\346\234\254\350\252\236"
1.8.7 :004 > s[-1].ord
=> 158

</code></pre>
--------------------------------------------------------------------------------
I got it.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Committed in trunk and 2.3-stable.
--------------------------------------------------------------------------------
"ending" is always negative value.
I think that I should correct it as follows.

<pre><code class="diff">
--- unified_diff.rb_org 2013-07-25 20:57:37.000000000 +0900
+++ unified_diff.rb 2013-07-25 21:23:36.000000000 +0900
@@ -206,12 +206,12 @@
end
ending = -1
while ending >= -(max - starting) && line_left[ending] == line_right[ending]
ending -= 1
end
- if (! "".respond_to?(:force_encoding)) && ending > (-1 * line_left.size)
- while line_left[ending].ord.between?(128, 191) && ending > -1
+ if (! "".respond_to?(:force_encoding))
+ while ending > (-1 * line_left.size) && line_left[ending].ord.between?(128, 191)
ending -= 1
end
end
unless starting == 0 && ending == -1
[starting, ending]
</code></pre>

--------------------------------------------------------------------------------
Jun NAITOH wrote:
> "ending" is always negative value.
> I think that I should correct it as follows.
>
Could you give me examples or tests?

--------------------------------------------------------------------------------
Sorry, note-10 sample code has a problem.

I rewrote the code, and added test code.

--------------------------------------------------------------------------------
Jun NAITOH wrote:
> Sorry, note-10 sample code has a problem.
>
> I rewrote the code, and added test code.

Thanks.
I have created new issue #14562.

--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリSCM_3 にセット
  • 対象バージョン2.3.1_71 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0