Skip to content

fix(markdown_parser): prevent unclosed <u> tags from pairing via emphasis algorithm#13134

Open
Jason-Shen2 wants to merge 1 commit into
warpdotdev:masterfrom
Jason-Shen2:fix/markdown-parser-underline-emphasis
Open

fix(markdown_parser): prevent unclosed <u> tags from pairing via emphasis algorithm#13134
Jason-Shen2 wants to merge 1 commit into
warpdotdev:masterfrom
Jason-Shen2:fix/markdown-parser-underline-emphasis

Conversation

@Jason-Shen2

Copy link
Copy Markdown

Summary

When two <u> underline start tags appear without closing </u> tags, they were incorrectly paired as an opener/closer pair through the emphasis algorithm, causing the literal <u> markers and surrounding text to be silently deleted.

Root Cause

<u> was tokenized as UnderlineStart with can_close set from right-flanking rules, allowing process_emphasis to match two <u> openers as a pair. Underline is only meant to be closed by an explicit </u> tag (handled by parse_underline), never by another <u>.

Fix

  1. Set can_close = false for UnderlineStart delimiters so <u> is never treated as a closing delimiter by process_emphasis
  2. Add a guard in can_open_for to reject UnderlineStart pairs (defense in depth)

Regression Tests

Added tests covering the cases from the issue:

  • <u><u> round-trips as literal text (was: empty line, all text deleted)
  • <u>a<u> preserves both <u> markers (was: a, both markers deleted)
  • a <u>word<u> b does not delete text (was: a word b, markers deleted)

Fixes #12863

…asis algorithm

When two <u> underline start tags appear without closing </u> tags,
they were incorrectly paired as an opener/closer pair through the
emphasis algorithm, causing the literal <u> markers and surrounding
text to be silently deleted.

Root cause: <u> was tokenized as UnderlineStart with can_close set from
right-flanking rules, allowing process_emphasis to match two <u> openers
as a pair. Underline is only meant to be closed by an explicit </u> tag
(handled by parse_underline), never by another <u>.

Fix:
- Set can_close = false for UnderlineStart delimiters so <u> is never
  treated as a closing delimiter by process_emphasis
- Add a guard in can_open_for to reject UnderlineStart pairs (defense
  in depth)

Adds regression tests for the cases from the issue:
- <u><u> should round-trip as literal text
- <u>a<u> should preserve both <u> markers
- a <u>word<u> b should not delete text

Fixes warpdotdev#12863
@cla-bot

cla-bot Bot commented Jun 28, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: zhenxing.shen.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label Jun 28, 2026
@oz-for-oss

oz-for-oss Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

@Jason-Shen2

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I reviewed this pull request and requested human review from: @kevinyang372.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR updates the inline Markdown delimiter handling so <u> start tags can no longer act as emphasis closers, while preserving explicit underline closing through </u>. It also adds regression coverage for unclosed underline-start sequences that previously dropped literal text.

Concerns

  • No blocking correctness, security, or spec-alignment concerns found in the attached diff.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot requested a review from kevinyang372 June 28, 2026 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

markdown_parser: unclosed <u> markers pair via the emphasis algorithm and delete surrounding text

1 participant