Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

機種依存文字が文字化けする不具合を修正 #4783

Merged
merged 3 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/config/eccube/packages/eccube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ parameters:
eccube_csv_export_separator: ,
# 出力エンコーディング
eccube_csv_export_encoding: SJIS-win
# 入力エンコーディング
eccube_csv_import_encoding: ['UTF-8', 'SJIS-win', 'SJIS', 'EUC-JP', 'ASCII', 'JIS']
# 日付のフォーマット
eccube_csv_export_date_format: 'Y-m-d H:i:s'
# 複数データの区切り文字
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function getImportData(UploadedFile $formFile)
}
} else {
// アップロードされたファイルがUTF-8以外は文字コード変換を行う
$encode = StringUtil::characterEncoding($file);
$encode = StringUtil::characterEncoding($file, $this->eccubeConfig['eccube_csv_import_encoding']);
if (!empty($encode) && $encode != 'UTF-8') {
$file = mb_convert_encoding($file, 'UTF-8', $encode);
}
Expand Down
26 changes: 26 additions & 0 deletions tests/Eccube/Tests/Web/Admin/Product/CsvImportControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -964,4 +964,30 @@ public function testDeleteImage()
$this->assertTrue(file_exists($dir . $DuplicatedImage->getFileName()));
$this->assertFalse(file_exists($dir . $NotDuplicatedImage->getFileName()));
}

/**
* @see https://github.com/EC-CUBE/ec-cube/issues/4781
*/
public function testSjisWinCsvTest()
{
// CSV生成
$csv = $this->createCsvAsArray();
$csv[1][2] = 'テスト①'; // 商品名:機種依存文字で設定
$csv[1][3] = 'sjis-win-test';
$this->filepath = $this->createCsvFromArray($csv);

// sjis-winに変換
$content = file_get_contents($this->filepath);
$content = mb_convert_encoding($content, 'sjis-win', 'UTF-8');
file_put_contents($this->filepath, $content);

$this->scenario();

$Product = $this->productRepo->findOneBy(['note' => 'sjis-win-test']);

// 文字化けしないことを確認
$this->expected = 'テスト①';
$this->actual = $Product->getName();
$this->verify();
}
}