fix(message-parser): inline keycap emojis starting with digits parse as plain text

Aperta
#44,032 3 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@SatyamPandey-07 ci sta già lavorando.

Dal 29/11/2026.

  • #44033 di @SatyamPandey-07 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
javascript, typescript
Ambito
backend, testing

Direzione di ricerca

Read packages/message-parser/src/grammar.pegjs around InlineItemPattern, the digit dispatch paths, and InlineEmoji; then review the existing emoji cases in packages/message-parser/tests/emoji.test.ts. Add inline keycap cases for 1️⃣, 0️⃣, and 8️⃣ and confirm they produce emoji nodes, while plain text still parses. Pull request #44033 is already open against this issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

type: bug

Description

In packages/message-parser/src/grammar.pegjs, the first-character dispatch in InlineItemPattern routes digits 0/8 to InlineItemAlphaOrEmoticon and 1-7/9 to InlineItemAlphaPath. Neither of these rules tries InlineEmoji before PlainRun, and PlainRun does not exclude digits or keycap combining characters (\uFE0F, \u20E3). As a result, PlainRun consumes inline keycap sequences such as 1️⃣, 0️⃣, or 8️⃣ as plain text before InlineEmoji (and UnicodeEmojiKeycapSequence) can match.

Standalone keycap messages (e.g., "1️⃣") still pass because BigEmoji runs before Inline, so existing tests in packages/message-parser/tests/emoji.test.ts do not catch this inline regression.

Steps to Reproduce

  1. Import parse from @rocket.chat/message-parser.
  2. Call parse('pick 1️⃣ now') (or parse('pick 0️⃣ now') / parse('pick 8️⃣ now')).
  3. Inspect the returned AST Paragraph children.
  4. Observe that 1️⃣ is emitted inside a PLAIN node instead of an EMOJI node.

Expected Behavior

parse('pick 1️⃣ now') should return a Paragraph containing:

  • plain('pick ')
  • emojiUnicode('1️⃣')
  • plain(' now')

Actual Behavior / Error Logs

// Actual AST output for parse('pick 1️⃣ now'):
// InlineItemPattern matches & [a-zA-Z1-79] -> InlineItemAlphaPath -> PlainRun
// PlainRun = run:$[^*_~`:\n<\[\]! \t\u00a0()\\|]+
// Consumes "1️⃣" as plain text instead of matching UnicodeEmojiKeycapSequence
[
  {
    type: 'PARAGRAPH',
    value: [
      { type: 'PLAIN_TEXT', value: 'pick 1️⃣ now' }
    ]
  }
]

Proposed Fix

Update packages/message-parser/src/grammar.pegjs so digit-starting inline inputs attempt InlineEmoji (or UnicodeEmojiKeycapSequence) before PlainRun:

  1. Route [08] and [1-79] (or add InlineEmoji before PlainRun on the digit dispatch paths / InlineItemDigitPath and InlineItemAlphaOrEmoticon for 0/8) so 1️⃣–9️⃣ and 0️⃣ match InlineEmoji before falling back to PlainRun.
  2. Add inline keycap regression test cases (e.g., 'pick 1️⃣ now', 'pick 0️⃣ now', 'pick 8️⃣ now') to packages/message-parser/tests/emoji.test.ts.
Lingua principale
TypeScript
Stelle
46.6k
Fork
14.2k
Merge medio
2g 21h
PR unite (30g)
302

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di RocketChat/Rocket.Chat

Tutte le issue di RocketChat/Rocket.Chat

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.