summaryrefslogtreecommitdiff
path: root/packages/backend/src/queue
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2024-05-02 21:06:10 +0000
committerdakkar <dakkar@thenautilus.net>2024-05-02 21:06:10 +0000
commitd0a2708f912b1ceaa0f40161d874fb5c72a72f4e (patch)
tree650324da99261d7910504dfbcaa0683c5b2121dc /packages/backend/src/queue
parentmerge: save and restore UI language together with other prefs - fixes #443 (!... (diff)
parentteach ReactionService about non-ASCII emoji names (diff)
downloadsharkey-d0a2708f912b1ceaa0f40161d874fb5c72a72f4e.tar.gz
sharkey-d0a2708f912b1ceaa0f40161d874fb5c72a72f4e.tar.bz2
sharkey-d0a2708f912b1ceaa0f40161d874fb5c72a72f4e.zip
merge: handle non-ASCII emoji names (!464)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/464 Approved-by: Leah <kevinlukej@gmail.com> Approved-by: Ember <acomputerdog@gmail.com> Approved-by: Marie <marie@kaifa.ch>
Diffstat (limited to 'packages/backend/src/queue')
-rw-r--r--packages/backend/src/queue/processors/ExportCustomEmojisProcessorService.ts2
-rw-r--r--packages/backend/src/queue/processors/ImportCustomEmojisProcessorService.ts13
2 files changed, 8 insertions, 7 deletions
diff --git a/packages/backend/src/queue/processors/ExportCustomEmojisProcessorService.ts b/packages/backend/src/queue/processors/ExportCustomEmojisProcessorService.ts
index e4eb4791bd..45087927a5 100644
--- a/packages/backend/src/queue/processors/ExportCustomEmojisProcessorService.ts
+++ b/packages/backend/src/queue/processors/ExportCustomEmojisProcessorService.ts
@@ -85,7 +85,7 @@ export class ExportCustomEmojisProcessorService {
});
for (const emoji of customEmojis) {
- if (!/^[a-zA-Z0-9_]+$/.test(emoji.name)) {
+ if (!/^[\p{Letter}\p{Number}\p{Mark}_+-]+$/u.test(emoji.name)) {
this.logger.error(`invalid emoji name: ${emoji.name}`);
continue;
}
diff --git a/packages/backend/src/queue/processors/ImportCustomEmojisProcessorService.ts b/packages/backend/src/queue/processors/ImportCustomEmojisProcessorService.ts
index 171809d25c..04ad74ee01 100644
--- a/packages/backend/src/queue/processors/ImportCustomEmojisProcessorService.ts
+++ b/packages/backend/src/queue/processors/ImportCustomEmojisProcessorService.ts
@@ -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,
});
const driveFile = await this.driveService.addFile({
user: null,
@@ -94,10 +95,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,