fix: wrap fields in quotes in user csv export

This commit is contained in:
Barış Soner Uşaklı
2026-01-21 18:31:58 -05:00
parent ec4e7ef1b7
commit 1b08aef2d0

View File

@@ -55,7 +55,8 @@ module.exports = function (User) {
fields: fieldsToExport, fields: fieldsToExport,
showIps: fieldsToExport.includes('ip'), showIps: fieldsToExport.includes('ip'),
}); });
const customUserFields = await db.getSortedSetRange('user-custom-fields', 0, -1);
const fieldsToWrapInQuotes = ['fullname', 'signature', 'aboutme', ...customUserFields];
if (!showIps && fields.includes('ip')) { if (!showIps && fields.includes('ip')) {
fields.splice(fields.indexOf('ip'), 1); fields.splice(fields.indexOf('ip'), 1);
} }
@@ -76,6 +77,11 @@ module.exports = function (User) {
if (Array.isArray(userIps[index])) { if (Array.isArray(userIps[index])) {
user.ip = userIps[index].join(','); user.ip = userIps[index].join(',');
} }
fieldsToWrapInQuotes.forEach((field) => {
if (user[field]) {
user[field] = `"${String(user[field])}"`;
}
});
}); });
const opts = { fields, header: false }; const opts = { fields, header: false };