Skip to content

fix(edge): nested lists and attribute > leaks in markdown negotiation - #732

Open
Anshumancanrock wants to merge 2 commits into
Project-HAMi:masterfrom
Anshumancanrock:fix/markdown-nested-lists-attr-gt
Open

fix(edge): nested lists and attribute > leaks in markdown negotiation#732
Anshumancanrock wants to merge 2 commits into
Project-HAMi:masterfrom
Anshumancanrock:fix/markdown-nested-lists-attr-gt

Conversation

@Anshumancanrock

@Anshumancanrock Anshumancanrock commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

Fixes the two follow-ups from #688.

Nested lists were getting flattened because <li>.*?</li> closed at the first nested </li>, so sub-items got promoted and parent steps renumbered. Walk ul/ol/li by depth instead, and unwrap <p> before list conversion so Docusaurus-style items don't come out as 1.\n\ntext.

Quoted > in attributes was leaking into the body (title="a > b"b">…) because tag scans use [^>]*. Mask those before the scans, restore after.

Also keep leading indent when collapsing spaces, otherwise nested list markers get wiped.

Which issue(s) this PR fixes:

Fixes #731

Checklist:

  • npm run lint and npm run format:check pass
  • npm run build succeeds for both en and zh
  • Chinese translation updated if English docs changed (or noted why not) (n/a, no docs touched)
  • Commits are signed off (git commit -s)

Summary by CodeRabbit

  • Bug Fixes

    • Improved Markdown conversion for nested ordered and unordered lists, multiline items, and incomplete lists.
    • Prevented > characters inside quoted HTML attributes from being misinterpreted during conversion.
    • Preserved indentation more reliably when processing formatted content.
  • Tests

    • Added regression coverage for nested lists and protected angle characters, including encoded values.

Signed-off-by: anshumancanrock <anshu.1239.as@gmail.com>
@hami-robot hami-robot Bot added the kind/bug Something isn't working label Aug 6, 2026
@hami-robot

hami-robot Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Anshumancanrock
Once this PR has been reviewed and has the lgtm label, please assign windsonsea for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploy Preview for project-hami ready!

Name Link
🔨 Latest commit b37b444
🔍 Latest deploy log https://app.netlify.com/projects/project-hami/deploys/6a755f6069b6220008a525eb
😎 Deploy Preview https://deploy-preview-732--project-hami.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@hami-robot hami-robot Bot added the size/L label Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Anshumancanrock, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 87523152-6198-45e3-965f-03228ae0d5b4

📥 Commits

Reviewing files that changed from the base of the PR and between ad61f69 and b37b444.

📒 Files selected for processing (2)
  • netlify/edge-functions/markdown-negotiation.js
  • test/markdown-negotiation.test.mjs
📝 Walkthrough

Walkthrough

The Markdown negotiation converter now protects > characters inside quoted HTML attributes and converts nested lists with depth-aware handling. Regression tests cover nested list rendering and quoted or entity-encoded attribute values.

Changes

Markdown negotiation parsing

Layer / File(s) Summary
Quoted attribute angle protection
netlify/edge-functions/markdown-negotiation.js, test/markdown-negotiation.test.mjs
The conversion pipeline protects > characters inside quoted attributes and restores them after Markdown assembly. Tests cover quoted and entity-encoded values.
Nested list conversion
netlify/edge-functions/markdown-negotiation.js, test/markdown-negotiation.test.mjs
convertLists replaces regex-only handling with depth-aware conversion for nested lists, multiline items, ordered markers, incomplete lists, and preserved indentation. Tests cover ordered and unordered nesting, including paragraph-wrapped items.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related issues

  • Project-HAMi/website issue 731 — The changes implement fixes for nested-list conversion and quoted-attribute angle handling.

Possibly related PRs

Sequence Diagram(s)

sequenceDiagram
  participant HTMLContent
  participant AttributeProtection
  participant MarkdownConverter
  participant ListConverter
  participant MarkdownDocument

  HTMLContent->>AttributeProtection: Protect quoted `>` characters
  AttributeProtection->>MarkdownConverter: Pass protected HTML
  MarkdownConverter->>ListConverter: Convert nested list structures
  ListConverter->>MarkdownDocument: Return formatted Markdown lists
  MarkdownConverter->>MarkdownDocument: Restore protected attribute characters
Loading

Suggested reviewers: mesutoezdil

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the two primary fixes: nested list handling and attribute > leaks in markdown negotiation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@netlify/edge-functions/markdown-negotiation.js`:
- Line 321: Update the HTML processing flow around the `<main>` extraction to
protect html before scanning the title, description, and main tags, preventing
`>` inside attributes from ending the match early. Keep protected characters
encoded throughout intermediate scans and restore them only in the final
Markdown result, then add a regression test covering a `<main>` attribute
containing `>`.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ddc641bb-232b-4649-8f80-22dbac295851

📥 Commits

Reviewing files that changed from the base of the PR and between ad61f69 and e37149b.

📒 Files selected for processing (2)
  • netlify/edge-functions/markdown-negotiation.js
  • test/markdown-negotiation.test.mjs

Comment thread netlify/edge-functions/markdown-negotiation.js Outdated
Signed-off-by: anshumancanrock <anshu.1239.as@gmail.com>
@Anshumancanrock
Anshumancanrock force-pushed the fix/markdown-nested-lists-attr-gt branch from f9b46fe to b37b444 Compare August 7, 2026 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested lists get flattened / > in attributes leaks into markdown

1 participant