Defect #13644
closedDiff - Internal Error
Description
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:
Files
Updated by Ivan Cenov over 13 years ago
I confirm.
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
Updated by Jongwook Choi over 13 years ago
- File unified_diff.rb.patch unified_diff.rb.patch added
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:
- 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)
I've submitted the patch.
Updated by Filou Centrinov over 13 years ago
Updated by Toshi MARUYAMA over 13 years ago
Filou Centrinov wrote:
Why not simply setting the encoding?
Because tests fail on Ruby 1.8.7.
Updated by Toshi MARUYAMA over 13 years ago
Updated by Toshi MARUYAMA over 13 years ago
Updated by Etienne Massip over 13 years ago
- Target version set to Candidate for next minor release
Updated by Toshi MARUYAMA over 13 years ago
- Target version changed from Candidate for next minor release to 2.3.1
Updated by Toshi MARUYAMA over 13 years ago
- Status changed from Confirmed to Closed
- Resolution set to Fixed
Committed in trunk and 2.3-stable.
Updated by Jun NAITOH over 13 years ago
"ending" is always negative value.
I think that I should correct it as follows.
--- 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]
Updated by Toshi MARUYAMA over 13 years ago
Jun NAITOH wrote:
"ending" is always negative value.
I think that I should correct it as follows.
Could you give me examples or tests?
Updated by Jun NAITOH over 13 years ago
Sorry, note-10 sample code has a problem.
I rewrote the code, and added test code.
Updated by Toshi MARUYAMA over 13 years ago
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.