mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-21 19:53:50 +01:00
[backend] Fix emojis with special characters
This is an adaptation of3968a6ca07
andada577bde6
Co-authored-by: Johann150 <johann.galle@protonmail.com>
This commit is contained in:
parent
299a20fb71
commit
197002df8a
@ -41,13 +41,10 @@ function normalizeHost(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseEmojiStr(emojiName: string, noteUserHost: string | null) {
|
function parseEmojiStr(emojiName: string, noteUserHost: string | null) {
|
||||||
const match = emojiName.match(/^(\w+)(?:@([\w.-]+))?$/);
|
// emojiName may be of the form `emoji@host`, turn it into a suitable form
|
||||||
if (!match) return { name: null, host: null };
|
const match = emojiName.split("@");
|
||||||
|
const name = match[0];
|
||||||
const name = match[1];
|
const host = toPunyNullable(normalizeHost(match[1], noteUserHost));
|
||||||
|
|
||||||
// ホスト正規化
|
|
||||||
const host = toPunyNullable(normalizeHost(match[2], noteUserHost));
|
|
||||||
|
|
||||||
return { name, host };
|
return { name, host };
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,9 @@ export async function exportCustomEmojis(
|
|||||||
|
|
||||||
for (const emoji of customEmojis) {
|
for (const emoji of customEmojis) {
|
||||||
const ext = mime.extension(emoji.type);
|
const ext = mime.extension(emoji.type);
|
||||||
const fileName = emoji.name + (ext ? `.${ext}` : "");
|
// there are some restrictions on file names, so to be safe the files are
|
||||||
|
// named after their database id instead of the actual emoji name
|
||||||
|
const fileName = emoji.id + (ext ? '.' + ext : '');
|
||||||
const emojiPath = `${path}/${fileName}`;
|
const emojiPath = `${path}/${fileName}`;
|
||||||
fs.writeFileSync(emojiPath, "", "binary");
|
fs.writeFileSync(emojiPath, "", "binary");
|
||||||
let downloaded = false;
|
let downloaded = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user