Skip to content

CardBuilder.MarkdownRender leaks raw HTML and table source onto the card #23

Description

@m1ngsama

CardBuilder.MarkdownRender renders GitHub issue and comment bodies onto the image card the QQ adapters receive through the broadcast fallback. Two constructs that are common in GitHub bodies come out as literal source.

Raw HTML blocks are truncated to 20 characters and drawn verbatim. The HtmlBlock default branch emits htmlRaw[..20] in LightSeaGreen (src/HuaJiBot.NET/Utils/CardBuilder.cs:413-447). On the repair-tickets cards in the Repair topic this shows up as the string below, which is exactly the first 20 characters of a collapsed section:

<details><summary>nb

HtmlInline has the same shape, drawing the bare tag in gray italic (src/HuaJiBot.NET/Utils/CardBuilder.cs:302).

Tables render as their source. Markdown.Parse(markdown) is called with no pipeline (src/HuaJiBot.NET/Utils/CardBuilder.cs:231), so no Markdig extension is enabled and GFM pipe tables are never recognized. The repair-tickets bodies land on the card as a | Field | Value | Description | header followed by the |---|---|---| separator row.

Both appear on the same card, so any repair ticket produces a card with four lines of unrendered source in the middle of it.

Direction, needs a decision before anyone starts:

  • Tables: build the pipeline once with new MarkdownPipelineBuilder().UsePipeTables().Build() and pass it to Markdown.Parse, then add a Table case to ProcessBlock. Laying a real table out as TextRuns is most of the work here.
  • HTML: decide whether to drop these blocks outright, the way HtmlBlockType.Comment already does, or unwrap the handful of tags GitHub bodies actually use — <details>, <summary>, <img>, <br>. Printing 20 characters of source helps nobody either way.

Not urgent while production is down (#22).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions