jmeter icon indicating copy to clipboard operation
jmeter copied to clipboard

JMeter does not support files with Chinese/Japanese characters

Open asfimport opened this issue 3 years ago • 2 comments

Ziven (Bug 66251): It appears hard coded ENCODING with ISO_8859_1 in file

src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/sampler/PostWriter.java as following: public static final String ENCODING = StandardCharsets.ISO_8859_1.name()

Severity: major OS: Linux

asfimport avatar Sep 05 '22 16:09 asfimport

Ziven (migrated from Bugzilla): Created attachment 1-UploadFileWithChineseCharactersInFilename.png: Choose a File With Chinese Characters In Filename to upload

Choose a File With Chinese Characters In Filename to upload

asfimport avatar Sep 13 '22 08:09 asfimport

Ziven (migrated from Bugzilla): Created attachment 2-CantShowChineseCharactersAsExpected.png: Step2. After the upload, it cant show Chinese Characters as expected

Step2. After the upload, it cant show Chinese Characters as expected

asfimport avatar Sep 13 '22 08:09 asfimport

Hi, I propose a solution to choose how to encode the file name in for a POST Multipart (Java Client implementation)

  1. <filename> and use Content encoding = ISO-8859-1 (Don't use Sampler Content encoding)
  2. <filename> and use Sampler Content Encoding Value (likes UTF-8 or ISO-8859-15)
  3. URLEncoder.encode(<filename>",<Sampler Content Encoding>") and use Sampler Content Encoding Value (likes UTF-8 or ISO-8859-15)
  4. <filename>; filename*=UTF-8''URLEncoder.encode(<filename>",UTF-8") and use Sampler Content Encoding Value= UTF-8

I think with this list choices, you can POST a file with a correct filename encode

E.g. with filename contains Greek Alphabet : 2) <filename> and use Sampler Content Encoding Value= UTF-8

POST http://localhost:8081/test/upload

POST data:
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="file1"; filename="Ελλάδα.txt"
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Content-Transfer-Encoding: binary


-----------------------------7d159c1302d0y0--
  1. <filename>; filename*=UTF-8''URLEncoder.encode(<filename>",UTF-8")
POST http://localhost:8081/test/upload

POST data:
-----------------------------7d159c1302d0y0
Content-Disposition: form-data; name="file1"; filename="Ελλάδα.txt; filename*=UTF-8''%CE%95%CE%BB%CE%BB%CE%AC%CE%B4%CE%B1.txt"
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Content-Transfer-Encoding: binary


-----------------------------7d159c1302d0y0--

New GUI for Files upload with a ComboBox to choose the filename encode method to use

HttpRequest_FileUpload_Combobox_greek_filename

vdaburon avatar Oct 03 '22 15:10 vdaburon

Thank you @asfimport for the migration and @vdaburon for your proposal!

xyziven avatar Oct 31 '22 14:10 xyziven

Duplicate of https://github.com/apache/jmeter/issues/4546

vlsi avatar Jun 14 '23 10:06 vlsi