1
0
Fork 0
mirror of https://github.com/paricafe/misskey.git synced 2025-04-21 06:16:11 -05:00

backend: ImportCustomEmojis normalization

This commit is contained in:
fly_mc 2024-11-19 00:09:00 +08:00
parent d64b0b3865
commit a380f0dbf1

View file

@ -79,13 +79,14 @@ export class ImportCustomEmojisProcessorService {
continue;
}
const emojiInfo = record.emoji;
if (!/^[a-zA-Z0-9_]+$/.test(emojiInfo.name)) {
this.logger.error(`invalid emojiname: ${emojiInfo.name}`);
const nameNfc = emojiInfo.name.normalize('NFC');
if (!/^[\p{Letter}\p{Number}\p{Mark}_+-]+$/u.test(nameNfc)) {
this.logger.error(`invalid emojiname: ${nameNfc}`);
continue;
}
const emojiPath = outputPath + '/' + record.fileName;
await this.emojisRepository.delete({
name: emojiInfo.name,
name: nameNfc,
});
try {
const driveFile = await this.driveService.addFile({
@ -95,10 +96,10 @@ export class ImportCustomEmojisProcessorService {
force: true,
});
await this.customEmojiService.add({
name: emojiInfo.name,
category: emojiInfo.category,
name: nameNfc,
category: emojiInfo.category?.normalize('NFC'),
host: null,
aliases: emojiInfo.aliases,
aliases: emojiInfo.aliases?.map((a: string) => a.normalize('NFC')),
driveFile,
license: emojiInfo.license,
isSensitive: emojiInfo.isSensitive,