Markdown: HTML inside code blocks and inline code isn't escaped

オープン 初心者向け
#3,814 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@KishanKanejiya23 がすでに取り組んでいます。

2026年10月28日 から。

  • #3823 @KishanKanejiya23 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
markdown, react, typescript
領域
frontend

調査の方向性

markdown.tsxから始めて、codeとcodespanのレンダラーを探してください。issueによると、どちらもテキストをエスケープせずに挿入します。既存のMarkdownコンポーネントのテストを読み、フェンス付きコードとインラインコード内のHTMLを扱うケースを追加してください。両方がエスケープされたテキストとして表示され、issueの期待される出力と一致すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

What versions are you using? (if relevant)

[email protected] (also on canary), [email protected], [email protected]

Describe the Bug

<Markdown> doesn't escape what's inside code blocks and inline code. If a fenced block or a code span contains HTML, the tags go into the email as real HTML, so a code sample showing <b>bold</b> comes out as bold text instead of the snippet.

The code and codespan renderers in markdown.tsx insert text as is, while marked's own renderers escape it.

What is affected (leave empty if unsure)

Markdown Component

Link to the code that reproduces this issue

The repro is short, so it's inline under To Reproduce. It only needs [email protected], [email protected] and [email protected].

To Reproduce

Save this as check.mjs and run it with node:

import { createElement as h } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { Markdown } from 'react-email';

const md = '```html\n<b>bold</b> & <i>x</i>\n```\n\nInline: `<br>`';
console.log(renderToStaticMarkup(h(Markdown, null, md)).replace(/ style="[^"]*"/g, ''));

With the inline styles stripped, the output contains <pre><code><b>bold</b> & <i>x</i> and <p>Inline: <code><br></code></p>.

Expected Behavior

The code gets escaped, the way marked's default renderer does it: &lt;b&gt;bold&lt;/b&gt; &amp; &lt;i&gt;x&lt;/i&gt; and <code>&lt;br&gt;</code>.

I'd like to send a PR for this with a test, if that's okay.

What's your node version? (if relevant)

26.7.0

主要言語
TypeScript
スター
19.9k
フォーク
1.1k
平均マージ
1日 15時間
マージ済み PR(30日)
49

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

resend/react-email のほかの issue

resend/react-email の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。