uiwjs / uiwjs/react-md-editor

Markdown crashes with specific HTML-like string input

Open
#652 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.9k
Forks
201
Avg merge
12m
Merged PRs (30d)
1

Description

Description

When providing the string <!DOCTYPE html><!-- <html>\n <head>\n as the source of the Markdown, the @uiw/react-md-editor crashes and throws an error: "Cannot read properties of null (reading 'data')".

Steps to Reproduce
  1. Initialize @uiw/react-md-editor in a React component.
  2. Set the Markdown content to <!DOCTYPE html><!-- <html>\n <head>\n.
  3. Observe the crash and the error message.
Expected Behavior

The editor should handle the input gracefully without crashing.

Actual Behavior

The editor crashes and throws an error: "Cannot read properties of null (reading 'data')".

Additional Information
  • Version: 4.0.4
  • OS: macOS Sonoma 14.5
  • Browser: Chrome 126.0.6478.127
Relevant Code
import React, { useState } from 'react';
import MDEditor from '@uiw/react-md-editor';
import rehypeSanitize from 'rehype-sanitize';

const MarkdownEditorExample = () => {
  const [markdown, setMarkdown] = useState('<!DOCTYPE html><!-- <html>\n  <head>\n');

  return (
    <div>
      <MDEditor.Markdown source={markdown} rehypePlugins={[rehypeSanitize]} />
    </div>
  );
};

export default MarkdownEditorExample;

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the crash with MDEditor.Markdown using the exact HTML-like source and rehypeSanitize shown in the issue. Start by tracing the Markdown rendering path for this input and the null value behind the reported data access. Done means the editor renders the input without crashing, with coverage for the reproduction case.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.