Skip to content

Markdown syntax is incorrectly parsed in post title field, when pasting #78956

@alanjacobmathew

Description

@alanjacobmathew

Description

Pasting text containing Markdown syntax (e.g. #) into the post title field results in loss of the original characters due to unintended Markdown conversion.

Step-by-step reproduction instructions

  1. Create a new post.
  2. Click into the post title field. Open the browser console
  3. Paste the following text:
    # 3 reason why

Expected Behavior

The title field should treat input as plain text and preserve all characters exactly as pasted

Actual Behavior

The pasted text is interpreted as Markdown and converted into a heading

Console

Received HTML (pasteHandler):

 <html>
<body>
<!--StartFragment--><span style="color: rgb(255, 255, 255); font-family: &quot;Monaspace Neon&quot;, ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: break-spaces; background-color: rgb(33, 40, 48); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"># 3 reason why</span><!--EndFragment-->
</body>
</html>
paste-handler.ts:40 Received plain text (pasteHandler):

 # 3 reason why
paste-handler.ts:40 Processed HTML piece:

 <h1>3 reason why</h1>

Screenshots, screen recording, code snippet

No response

Environment info

WP 7.0, default GB editor, TT5, GeneratePress
Chromium, Win 10

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions