diff --git a/README.md b/README.md index 6d0ed94b..c2e62411 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ Key | Description `fileFilter` | Function to control which files are accepted `limits` | Limits of the uploaded data `preservePath` | Keep the full path of files instead of just the base name -`defParamCharset` | Default character set to use for values of part header parameters (e.g. filename) that are not extended parameters (that contain an explicit charset). Default: `'latin1'` +`defParamCharset` | Default character set to use for values of part header parameters (e.g. filename) that are not extended parameters (that contain an explicit charset). Default: `'utf8'` In an average web app, only `dest` might be required, and configured as shown in the following example. diff --git a/doc/README-ar.md b/doc/README-ar.md index 0b7a9149..314e5dad 100644 --- a/doc/README-ar.md +++ b/doc/README-ar.md @@ -126,7 +126,7 @@ app.post('/profile', upload.none(), function (req, res, next) { `fileFilter` | دالة للسيطرة على الملفات التي يتم قبولها `limits` | حدود البيانات التي تم تحميلها `preservePath` | الاحتفظ بالمسار الكامل للملفات بدلاً من الاسم الأساسي -`defParamCharset` | مجموعة الأحرف الافتراضية لاستخدامها لقيم معاملات رأس الجزء (مثل اسم الملف) التي ليست معاملات موسعة (لا تحتوي على مجموعة أحرف صريحة). الافتراضي: `'latin1'` +`defParamCharset` | مجموعة الأحرف الافتراضية لاستخدامها لقيم معاملات رأس الجزء (مثل اسم الملف) التي ليست معاملات موسعة (لا تحتوي على مجموعة أحرف صريحة). الافتراضي: `'utf8'` في تطبيق ويب متوسط ​​، قد تكون هناك حاجة فقط إلى `dest`، وتكوينها كما هو موضح في المثال التالي : diff --git a/doc/README-es.md b/doc/README-es.md index 728d8193..0855fcfc 100644 --- a/doc/README-es.md +++ b/doc/README-es.md @@ -135,7 +135,7 @@ Clave (key) | Descripción `fileFilter` | Función para controlar qué archivos son aceptados `limits` | Límites de los datos subidos `preservePath` | Mantiene la ruta completa de la ubicación de los archivos, en vez de sólo sus nombres -`defParamCharset` | Conjunto de caracteres por defecto para usar en valores de parámetros de encabezados de partes (ej. nombre de archivo) que no son parámetros extendidos (que contienen un conjunto de caracteres explícito). Por defecto: `'latin1'` +`defParamCharset` | Conjunto de caracteres por defecto para usar en valores de parámetros de encabezados de partes (ej. nombre de archivo) que no son parámetros extendidos (que contienen un conjunto de caracteres explícito). Por defecto: `'utf8'` En la aplicación web promedio es probable que sólo se requiera `dest`, siendo configurado como en el siguiente ejemplo: diff --git a/doc/README-fr.md b/doc/README-fr.md index fcdde77e..369febc8 100644 --- a/doc/README-fr.md +++ b/doc/README-fr.md @@ -137,7 +137,7 @@ Clé | Description `fileFilter` | Fonction pour contrôler quels fichiers sont acceptés `limits` | Limites des données téléchargées `preservePath` | Conservez le chemin complet des fichiers au lieu du nom de base uniquement -`defParamCharset` | Jeu de caractères par défaut à utiliser pour les valeurs des paramètres d'en-tête de partie (par exemple, nom de fichier) qui ne sont pas des paramètres étendus (qui contiennent un jeu de caractères explicite). Par défaut : `'latin1'` +`defParamCharset` | Jeu de caractères par défaut à utiliser pour les valeurs des paramètres d'en-tête de partie (par exemple, nom de fichier) qui ne sont pas des paramètres étendus (qui contiennent un jeu de caractères explicite). Par défaut : `'utf8'` Dans une application Web moyenne, seul `dest` peut être requis et configuré comme indiqué dans l'exemple suivant. diff --git a/doc/README-ko.md b/doc/README-ko.md index 59c5a165..e2ae97a1 100644 --- a/doc/README-ko.md +++ b/doc/README-ko.md @@ -102,7 +102,7 @@ Key | Description `fileFilter` | 어떤 파일을 허용할지 제어하는 함수 `limits` | 업로드 된 데이터의 한도 `preservePath` | 파일의 base name 대신 보존할 파일의 전체 경로 -`defParamCharset` | 확장 매개변수가 아닌 부분 헤더 매개변수 값(예: 파일명)에 사용할 기본 문자 집합(명시적 문자 집합을 포함하지 않음). 기본값: `'latin1'` +`defParamCharset` | 확장 매개변수가 아닌 부분 헤더 매개변수 값(예: 파일명)에 사용할 기본 문자 집합(명시적 문자 집합을 포함하지 않음). 기본값: `'utf8'` 보통의 웹 앱에서는 `dest` 옵션 정도만 필요할지도 모릅니다. 설정 방법은 아래의 예제에 나와있습니다. diff --git a/doc/README-pt-br.md b/doc/README-pt-br.md index 15c6c031..cffc48a1 100644 --- a/doc/README-pt-br.md +++ b/doc/README-pt-br.md @@ -137,7 +137,7 @@ Key | Descrição `fileFilter` | Função para controlar quais arquivos são aceitos `limits` | Limites dos dados enviados `preservePath` | Mantenha o caminho completo dos arquivos em vez de apenas o nome base -`defParamCharset` | Conjunto de caracteres padrão para usar em valores de parâmetros de cabeçalho de parte (por exemplo, nome do arquivo) que não são parâmetros estendidos (que contêm um conjunto de caracteres explícito). Padrão: `'latin1'` +`defParamCharset` | Conjunto de caracteres padrão para usar em valores de parâmetros de cabeçalho de parte (por exemplo, nome do arquivo) que não são parâmetros estendidos (que contêm um conjunto de caracteres explícito). Padrão: `'utf8'` Em um web app básico, somente o `dest` pode ser necessário, e configurado como mostrado no exemplo a seguir: diff --git a/doc/README-ru.md b/doc/README-ru.md index 484b7d8f..c65d5d9d 100644 --- a/doc/README-ru.md +++ b/doc/README-ru.md @@ -109,7 +109,7 @@ Multer принимает объект с опциями. Базовая опц `fileFilter` | Функция для контроля принятия файлов `limits` | Ограничения по загрузке `preservePath` | Сохранять полный путь к файлам вместо только базового имени -`defParamCharset` | Кодировка по умолчанию для значений параметров заголовков частей (например, имя файла), которые не являются расширенными параметрами (не содержат явную кодировку). По умолчанию: `'latin1'` +`defParamCharset` | Кодировка по умолчанию для значений параметров заголовков частей (например, имя файла), которые не являются расширенными параметрами (не содержат явную кодировку). По умолчанию: `'utf8'` Обычно для веб-приложения нужно обязательно переопределить `dest`, как показано в примере ниже. diff --git a/doc/README-uz.md b/doc/README-uz.md index 0054d2f4..c4e1796e 100644 --- a/doc/README-uz.md +++ b/doc/README-uz.md @@ -113,7 +113,7 @@ Kalit(key) | Ta'rif `fileFilter` | Qaysi fayllar qabul qilinishini boshqarish funksiyasi `limits` | Yuklash chegarasi `preservePath` | Asosiy nom o'rniga fayllarning to'liq yo'lini saqlash -`defParamCharset` | Kengaytirilgan parametrlar bo'lmagan qism sarlavha parametrlari qiymatlari (masalan, fayl nomi) uchun ishlatish uchun standart belgilar to'plami (aniq belgilar to'plamini o'z ichiga olmaydi). Standart: `'latin1'` +`defParamCharset` | Kengaytirilgan parametrlar bo'lmagan qism sarlavha parametrlari qiymatlari (masalan, fayl nomi) uchun ishlatish uchun standart belgilar to'plami (aniq belgilar to'plamini o'z ichiga olmaydi). Standart: `'utf8'` O'rtacha veb-ilovada faqat `dest` kerak bo'lishi mumkin va quyidagicha sozlanishi mumkin diff --git a/doc/README-vi.md b/doc/README-vi.md index a72925ec..afef6e00 100644 --- a/doc/README-vi.md +++ b/doc/README-vi.md @@ -117,7 +117,7 @@ Dưới đây là các tùy chọn mà bạn có thể sử dụng: | `fileFilter` | Hàm để xử lý chỉ những file nào mới được chấp nhận | | `limits` | Giới hạn dung lượng file được upload | | `preservePath` | Giữ đầy đủ đường dẫn tới file thay vì chỉ tên file | -| `defParamCharset` | Bộ ký tự mặc định để sử dụng cho các giá trị tham số tiêu đề phần (ví dụ: tên tệp) không phải là tham số mở rộng (không chứa bộ ký tự rõ ràng). Mặc định: `'latin1'` | +| `defParamCharset` | Bộ ký tự mặc định để sử dụng cho các giá trị tham số tiêu đề phần (ví dụ: tên tệp) không phải là tham số mở rộng (không chứa bộ ký tự rõ ràng). Mặc định: `'utf8'` | Nói chung với web app, chỉ `dest` mới cần khai báo, như bên dưới: diff --git a/doc/README-zh-cn.md b/doc/README-zh-cn.md index 5dcb6a97..d743fbd3 100644 --- a/doc/README-zh-cn.md +++ b/doc/README-zh-cn.md @@ -104,7 +104,7 @@ Key | Description `fileFilter` | 文件过滤器,控制哪些文件可以被接受 `limits` | 限制上传的数据 `preservePath` | 保存包含文件名的完整文件路径 -`defParamCharset` | 用于部分标头参数值(例如文件名)的默认字符集,这些参数不是扩展参数(不包含显式字符集)。默认值:`'latin1'` +`defParamCharset` | 用于部分标头参数值(例如文件名)的默认字符集,这些参数不是扩展参数(不包含显式字符集)。默认值:`'utf8'` 通常,一般的网页应用,只需要设置 `dest` 属性,像这样: diff --git a/index.js b/index.js index 1dbfaacb..61a05b16 100644 --- a/index.js +++ b/index.js @@ -19,7 +19,7 @@ function Multer (options) { this.limits = options.limits this.preservePath = options.preservePath - this.defParamCharset = options.defParamCharset || 'latin1' + this.defParamCharset = options.defParamCharset || 'utf8' this.fileFilter = options.fileFilter || allowAll } diff --git a/test/def-param-charset.js b/test/def-param-charset.js index d292c9b4..d8ad2f9c 100644 --- a/test/def-param-charset.js +++ b/test/def-param-charset.js @@ -31,12 +31,12 @@ describe('defParamCharset', function () { rimraf(uploadDir, done) }) - it('should use latin1 as default charset for non-extended parameters', function (done) { + it('should use utf-8 as default charset for non-extended parameters', function (done) { var req = new stream.PassThrough() var boundary = 'AaB03x' - // Create a filename with latin1 characters (e.g., café encoded as latin1) - // In latin1: é = 0xE9 + // Create a filename with utf-8 characters (e.g., café encoded as utf-8) + // In utf-8: é = 0xC3 0xA9 var bodyParts = [ '--' + boundary, 'Content-Disposition: form-data; name="testfile"; filename="caf', @@ -47,11 +47,11 @@ describe('defParamCharset', function () { '--' + boundary + '--' ] - // Create buffer with proper latin1 encoding + // Create buffer with proper utf-8 encoding var bodyBuffer = Buffer.concat([ Buffer.from(bodyParts[0] + '\r\n', 'ascii'), Buffer.from(bodyParts[1], 'ascii'), - Buffer.from([0xE9]), // é in latin1 + Buffer.from([0xC3, 0xA9]), // é in UTF-8 Buffer.from(bodyParts[2] + '\r\n', 'ascii'), Buffer.from(bodyParts[3] + '\r\n', 'ascii'), Buffer.from(bodyParts[4] + '\r\n', 'ascii'), @@ -69,7 +69,7 @@ describe('defParamCharset', function () { upload.single('testfile')(req, null, function (err) { assert.ifError(err) - // With latin1 (default), the filename should be interpreted as latin1 + // With utf-8 (default), the filename should be interpreted as utf-8 assert.strictEqual(req.file.originalname, 'café.txt') assert.strictEqual(req.file.fieldname, 'testfile') @@ -85,14 +85,14 @@ describe('defParamCharset', function () { cb(null, file.originalname) } }), - defParamCharset: 'utf8' + defParamCharset: 'latin1' // ISO-8859-1, where é is 0xE9 }) var req = new stream.PassThrough() var boundary = 'AaB03x' - // Create a filename with UTF-8 characters (e.g., café encoded as UTF-8) - // In UTF-8: é = 0xC3 0xA9 + // Create a filename with Latin1 characters (e.g., café encoded as Latin1) + // In Latin1: é = 0xE9 var bodyParts = [ '--' + boundary, 'Content-Disposition: form-data; name="testfile"; filename="caf', @@ -103,11 +103,11 @@ describe('defParamCharset', function () { '--' + boundary + '--' ] - // Create buffer with proper UTF-8 encoding + // Create buffer with proper Latin1 encoding var bodyBuffer = Buffer.concat([ Buffer.from(bodyParts[0] + '\r\n', 'ascii'), Buffer.from(bodyParts[1], 'ascii'), - Buffer.from([0xC3, 0xA9]), // é in UTF-8 + Buffer.from([0xE9]), // é in Latin1 Buffer.from(bodyParts[2] + '\r\n', 'ascii'), Buffer.from(bodyParts[3] + '\r\n', 'ascii'), Buffer.from(bodyParts[4] + '\r\n', 'ascii'), @@ -125,7 +125,7 @@ describe('defParamCharset', function () { customUpload.single('testfile')(req, null, function (err) { assert.ifError(err) - // With utf8, the filename should be interpreted as utf8 + // With latin1, the filename should be interpreted as latin1 assert.strictEqual(req.file.originalname, 'café.txt') assert.strictEqual(req.file.fieldname, 'testfile')