Project

General

Profile

Actions

Defect #7096

closed

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

Added by Kioma Aldecoa almost 14 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Ruby support
Target version:
-
Start date:
2010-12-11
Due date:
% Done:

0%

Estimated time:
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. ExcelClosed2010-12-03

Actions
Related to Redmine - Defect #8368: Bad decimal separator in time entry CSVClosedToshi MARUYAMA2011-05-13

Actions
Related to Redmine - Defect #6621: Multibyte symbols are wrongly displayed in issues CSV export (ISO-8859)Closed2010-10-11

Actions
Related to Redmine - Defect #8549: Export CSV has character encoding errorClosedToshi MARUYAMA2011-06-07

Actions
Related to Redmine - Feature #4050: Ruby 1.9 supportClosed2009-10-18

Actions
Actions

Also available in: Atom PDF