Defect #7096

CSV Issues Export + Ruby 1.9 + Thin + non-ascii characters causes "invalid byte sequence in US-ASCII"

Added by Kioma Aldecoa over 6 years ago. Updated about 2 years ago.

Status:ClosedStart date:2010-12-11
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Ruby support
Target version:-
Resolution: Affected version:

Description

When exporting an issue list to CSV, if the issue list has a non-us ascii character, a 500 is produced with this in the logs:

ArgumentError (invalid byte sequence in US-ASCII):
  <internal:prelude>:8:in `synchronize'
  thin (1.2.7) lib/thin/connection.rb:76:in `block in pre_process'
  thin (1.2.7) lib/thin/connection.rb:74:in `catch'
  thin (1.2.7) lib/thin/connection.rb:74:in `pre_process'
  thin (1.2.7) lib/thin/connection.rb:57:in `process'
  thin (1.2.7) lib/thin/connection.rb:42:in `receive_data'
  eventmachine (0.12.10) lib/eventmachine.rb:256:in `run_machine'
  eventmachine (0.12.10) lib/eventmachine.rb:256:in `run'
  thin (1.2.7) lib/thin/backends/base.rb:57:in `start'
  thin (1.2.7) lib/thin/server.rb:156:in `start'
  thin (1.2.7) lib/thin/controllers/controller.rb:80:in `start'
  thin (1.2.7) lib/thin/runner.rb:177:in `run_command'
  thin (1.2.7) lib/thin/runner.rb:143:in `run!'
  thin (1.2.7) bin/thin:6:in `<main>'

Changing this in source:/trunk/app/controllers/issues_controller.rb@4515 fixed it, at least in that it does the export (non-ascii characters still don't seem quite right but they never really do and at least it exports).

Index: app/controllers/issues_controller.rb
===================================================================
--- app/controllers/issues_controller.rb        (revision 4515)
+++ app/controllers/issues_controller.rb        (working copy)
@@ -92,1 +92,1 @@
-        format.csv  { send_data(issues_to_csv(@issues, @project), :type => 'text/csv; header=present', :filename => 'export.csv') }
+        format.csv  { send_data(issues_to_csv(@issues, @project).force_encoding('ASCII-8BIT'), :type => 'text/csv; header=present', :filename => 'export.csv') }

As visible above, just added .force_encoding() there.


Related issues

Related to Redmine - Defect #7039: CSV export. Line breaks. Excel Closed 2010-12-03
Related to Redmine - Defect #8368: Bad decimal separator in time entry CSV Closed 2011-05-13
Related to Redmine - Defect #6621: Multibyte symbols are wrongly displayed in issues CSV exp... Closed 2010-10-11
Related to Redmine - Defect #8549: Export CSV has character encoding error Closed 2011-06-07
Related to Redmine - Feature #4050: Ruby 1.9 support Closed 2009-10-18

History

#1 Updated by Jean-Philippe Lang over 6 years ago

  • Category set to Ruby support

FYI, ruby 1.9 is not supported. See RedmineInstall.

#2 Updated by Kioma Aldecoa over 6 years ago

I know, but we have it working pretty well in 1.9 with a few patches like this. Just thought I would post them here for when it does become supported.

#3 Updated by Jean-Baptiste Barth over 6 years ago

  • Target version set to Unplanned
  • Affected version (unused) set to devel

Yes, but for now, ruby 1.8.6 and 1.8.7 are still the main ruby versions supported (often the default choice in stable distributions). If we do this directly, most people would see undefined method `force_encoding' for "...":String, not good. There's something going on in #4050 but it's not a priority for 1.1.0.

#4 Updated by Mischa The Evil over 6 years ago

"Corrected" the issue description.

#5 Updated by Toshi MARUYAMA about 6 years ago

  • Assignee set to Toshi MARUYAMA
  • Target version changed from Unplanned to 1.3.0

#6 Updated by Toshi MARUYAMA over 5 years ago

  • Target version changed from 1.3.0 to Unplanned

#7 Updated by Toshi MARUYAMA over 2 years ago

  • Status changed from New to Closed
  • Assignee deleted (Toshi MARUYAMA)

This issue is too old.
Redmine 1.4 and Redmine 2.x support Ruby >= 1.9.

#8 Updated by Toshi MARUYAMA about 2 years ago

  • Target version deleted (Unplanned)

Also available in: Atom PDF