Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion doc/README-ar.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ app.post('/profile', upload.none(), function (req, res, next) {
`fileFilter` | دالة للسيطرة على الملفات التي يتم قبولها
`limits` | حدود البيانات التي تم تحميلها
`preservePath` | الاحتفظ بالمسار الكامل للملفات بدلاً من الاسم الأساسي
`defParamCharset` | مجموعة الأحرف الافتراضية لاستخدامها لقيم معاملات رأس الجزء (مثل اسم الملف) التي ليست معاملات موسعة (لا تحتوي على مجموعة أحرف صريحة). الافتراضي: `'latin1'`
`defParamCharset` | مجموعة الأحرف الافتراضية لاستخدامها لقيم معاملات رأس الجزء (مثل اسم الملف) التي ليست معاملات موسعة (لا تحتوي على مجموعة أحرف صريحة). الافتراضي: `'utf8'`

في تطبيق ويب متوسط ​​، قد تكون هناك حاجة فقط إلى `dest`، وتكوينها كما هو موضح في
المثال التالي :
Expand Down
2 changes: 1 addition & 1 deletion doc/README-es.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion doc/README-fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion doc/README-ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Key | Description
`fileFilter` | 어떤 파일을 허용할지 제어하는 함수
`limits` | 업로드 된 데이터의 한도
`preservePath` | 파일의 base name 대신 보존할 파일의 전체 경로
`defParamCharset` | 확장 매개변수가 아닌 부분 헤더 매개변수 값(예: 파일명)에 사용할 기본 문자 집합(명시적 문자 집합을 포함하지 않음). 기본값: `'latin1'`
`defParamCharset` | 확장 매개변수가 아닌 부분 헤더 매개변수 값(예: 파일명)에 사용할 기본 문자 집합(명시적 문자 집합을 포함하지 않음). 기본값: `'utf8'`

보통의 웹 앱에서는 `dest` 옵션 정도만 필요할지도 모릅니다. 설정 방법은 아래의 예제에 나와있습니다.

Expand Down
2 changes: 1 addition & 1 deletion doc/README-pt-br.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion doc/README-ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Multer принимает объект с опциями. Базовая опц
`fileFilter` | Функция для контроля принятия файлов
`limits` | Ограничения по загрузке
`preservePath` | Сохранять полный путь к файлам вместо только базового имени
`defParamCharset` | Кодировка по умолчанию для значений параметров заголовков частей (например, имя файла), которые не являются расширенными параметрами (не содержат явную кодировку). По умолчанию: `'latin1'`
`defParamCharset` | Кодировка по умолчанию для значений параметров заголовков частей (например, имя файла), которые не являются расширенными параметрами (не содержат явную кодировку). По умолчанию: `'utf8'`

Обычно для веб-приложения нужно обязательно переопределить `dest`, как показано в примере ниже.

Expand Down
2 changes: 1 addition & 1 deletion doc/README-uz.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion doc/README-vi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion doc/README-zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Key | Description
`fileFilter` | 文件过滤器,控制哪些文件可以被接受
`limits` | 限制上传的数据
`preservePath` | 保存包含文件名的完整文件路径
`defParamCharset` | 用于部分标头参数值(例如文件名)的默认字符集,这些参数不是扩展参数(不包含显式字符集)。默认值:`'latin1'`
`defParamCharset` | 用于部分标头参数值(例如文件名)的默认字符集,这些参数不是扩展参数(不包含显式字符集)。默认值:`'utf8'`

通常,一般的网页应用,只需要设置 `dest` 属性,像这样:

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
24 changes: 12 additions & 12 deletions test/def-param-charset.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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'),
Expand All @@ -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')

Expand All @@ -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',
Expand All @@ -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'),
Expand All @@ -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')

Expand Down
Loading