Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: U+FE0Fなどがそのまま絵文字としてパースされてしまう #137

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/internal/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,10 @@ export const language = P.createLanguage({

unicodeEmoji: r => {
const emoji = RegExp(twemojiRegex.source);
return P.regexp(emoji).map(content => M.UNI_EMOJI(content));
return P.regexp(emoji).map(content => {
// 異体字セレクタのみの場合は空文字として返す
return /^[\uFE00-\uFE0F]+$/u.test(content) ? M.TEXT('') : M.UNI_EMOJI(content);
zyoshoka marked this conversation as resolved.
Show resolved Hide resolved
});
},

plainTag: r => {
Expand Down
6 changes: 6 additions & 0 deletions test/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ describe('SimpleParser', () => {
const output = [TEXT('あ'), EMOJI_CODE('bar'), TEXT('い')];
assert.deepStrictEqual(mfm.parseSimple(input), output);
});

test('U+FE0F', () => {
ikasoba marked this conversation as resolved.
Show resolved Hide resolved
const input = '\uFE0F';
const output = [TEXT('')];
assert.deepStrictEqual(mfm.parseSimple(input), output);
})
});

test('disallow other syntaxes', () => {
Expand Down