プロジェクト

全般

プロフィール

Vote #78473

完了

CSV Importer - handle UndefinedConversionErrors

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

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

0%

予定工数:
category_id:
15
version_id:
128
issue_org_id:
25861
author_id:
40856
assigned_to_id:
1
comments:
5
status_id:
5
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

The CSV import already handles a couple of Exceptions that may happen when the user-selected encoding does not match the real encoding of the CSV (or it contains otherwise illegal byte sequences). We recently encountered @Encoding::UndefinedConversionError@, which is not yet caught by that error handling. The attached patches add a test case and a fix for that.


journals

We can reproduce the problem with the test in attachment:0001-adds-failing-test-case-for-import-with-wrong-encodin.patch. Setting target version to 3.2.7.

By the way, the encoding of the file @invalid-Shift_JIS.csv@ is valid CP932. Shift_JIS and CP932 are almost identical, but CP932 includes more characters.

<pre>
$ iconv -f cp932 -t utf8 test/fixtures/files/invalid-Shift_JIS.csv

</pre>
--------------------------------------------------------------------------------
Go MAEDA wrote:
> We can reproduce the problem with the test in attachment:0001-adds-failing-test-case-for-import-with-wrong-encodin.patch. Setting target version to 3.2.7.

The test passes for me with ruby 2.0 (I would get a Encoding::InvalidByteSequenceError). Maybe we could simply rescue @EncodingError@ which is the base class for encoding errors?
--------------------------------------------------------------------------------
Jean-Philippe Lang wrote:
> Maybe we could simply rescue @EncodingError@ which is the base class for encoding errors?

I agree, caching EncodingError is better. We can simplify the code and catch all errors caused by iconv.

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

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

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

Admin Redmine さんが3年以上前に更新

  • カテゴリImporters_15 にセット
  • 対象バージョン3.2.7_128 にセット

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

いいね!0
いいね!0