-
Notifications
You must be signed in to change notification settings - Fork 295
Trailing HTML comment parsing #1069
Copy link
Copy link
Open
Labels
P3Low-risk cleanup, docs, polish, ergonomics, or speculative feature.Low-risk cleanup, docs, polish, ergonomics, or speculative feature.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Description
Metadata
Metadata
Assignees
Labels
P3Low-risk cleanup, docs, polish, ergonomics, or speculative feature.Low-risk cleanup, docs, polish, ergonomics, or speculative feature.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Priority
None yet
Summary
trailingHtmlCommentscan return an "HTML comment" that spans visible prose. Itscans backward from the end of a comment body, pairing each
-->with the nearestpreceding
<!--, without checking that the two actually delimit one comment. Astray
-->in prose therefore bridges back to an earlier opener and swallowseverything in between — including any real ClawSweeper marker in that span.
Impact
This is the parser that recovers ClawSweeper's durable state markers from its own
published comment. When the bridge happens, the marker inside the swallowed span is
no longer independently recoverable:
returns
The first entry is not a comment. It contains an interior
-->and visible text.-->is not exotic in these bodies: Mermaid flowchart edges are literallyA --> B,and ClawSweeper renders a Mermaid architecture diagram in its own reviews. Rust,
Haskell, and ASCII diagrams produce it too.
Reachability — please read before rating severity
I could not construct a body from the real renderer that triggers this, and I
tried hard. The trigger needs all three of:
<!--in the body to bridge back to;-->after it;Four realistic bodies — a Mermaid diagram in a closed fence, the same with an
unclosed fence, prose ending in an arrow, and a table cell ending in an arrow —
all parse correctly even today, because condition 1 is missing. The durable
comment's only mid-body opener is the
<!-- clawsweeper-review-history -->markerthat
renderReviewHistorySectionemits, and</details>always follows it beforeany trailing prose.
Both consumers are also fail-safe today:
clawsweeper-review-comment-state.tsanchors both ends with[^>]*, so a blobcontaining
>fails to match and the marker is ignored;review-recovery-label-backfill.tsuses a start-anchored matcher and then scansthe whole entry for
name=value, but itscanonicalcheck is strictly anchored,so a blob makes the recovery label be retained rather than wrongly cleared.
So this is a latent parser defect that is currently safe by accident of its
consumers' regexes, not a live incident. The reason it is still worth fixing:
review-recovery-label-backfill.tsharvests attributes from the entire entry witha loose matcher. If a blob ever satisfies its
canonicalcheck — one regexrefactor away — prose-derived attributes become authoritative for a
label-clearing decision.
Rate it accordingly; I would not call it more than a P3.
Root cause
src/review-comment-markers.ts:An HTML comment ends at its first
-->. The pairing above never verifies that.Suggested fix
Reject the candidate unless the opener's first terminator is the one being
matched:
Anything else means prose lies between them, so the trailing block has ended. This
makes the function honor its documented contract — "the final contiguous comment
block" — and changes nothing for bodies with a clean trailing block.
Existing coverage gap
test/review-comment-markers.test.tscovers the mirror case (prose containing anunmatched opener) and an adversarial unterminated suffix. The unmatched
closer is the untested sibling.
Environment
openclaw/clawsweeper@0588bda9local-container)