mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-14 02:27:49 +01:00
fix: wrap fields in quotes in user csv export
This commit is contained in:
@@ -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 };
|
||||||
|
|||||||
Reference in New Issue
Block a user