diff --git a/packages/megalodon/src/misskey.ts b/packages/megalodon/src/misskey.ts
index ca418439e..5e24e49f8 100644
--- a/packages/megalodon/src/misskey.ts
+++ b/packages/megalodon/src/misskey.ts
@@ -1280,8 +1280,8 @@ export default class Misskey implements MegalodonInterface {
status.mentions = (await this.getMentions(status.plain_content!, cache)).filter(p => p != null);
for (const m of status.mentions.filter((value, index, array) => array.indexOf(value) === index)) {
if (m.acct == m.username)
- status.content = status.content.replace(`@${m.acct}@${this.baseUrlToHost(this.baseUrl)}`, `@${m.acct}`);
- status.content = status.content.replace(`@${m.acct}`, `@${m.acct}`);
+ status.content = status.content.replace(new RegExp(`(?<=^|\\s|>)@${m.acct}@${this.baseUrlToHost(this.baseUrl)}(?=[^a-zA-Z0-9]|$)`, 'g'), `@${m.acct}`);
+ status.content = status.content.replace(new RegExp(`(?<=^|\\s|>)@${m.acct}(?=[^a-zA-Z0-9]|$)`, 'g'), `@${m.acct}`);
}
return status;
}
@@ -1292,7 +1292,7 @@ export default class Misskey implements MegalodonInterface {
if (text == undefined)
return mentions;
- const mentionMatch = text.matchAll(/(?<=^|\s)@(?.*?)(?:@(?.*?)|)(?=\s|$)/g);
+ const mentionMatch = text.matchAll(/(?<=^|\s)@(?[a-zA-Z0-9_]+)(?:@(?[a-zA-Z0-9-.]+\.[a-zA-Z0-9-]+)|)(?=[^a-zA-Z0-9]|$)/g,);
for (const m of mentionMatch) {
try {
@@ -2489,7 +2489,7 @@ export default class Misskey implements MegalodonInterface {
}
try {
- const match = q.match(/^@(?.*?)(?:@(?.*?)|)$/);
+ const match = q.match(/^@(?[a-zA-Z0-9_]+)(?:@(?[a-zA-Z0-9-.]+\.[a-zA-Z0-9-]+)|)$/);
if (match) {
const lookupQuery = {
username: match.groups?.user,