Repository navigation
fix(intake): drop style, script, template and comment text from HTML - #476
Conversation
StripTags only removed the <...> tokens and kept the text between them, so an uploaded HTML page's inline CSS and JS, and any comment containing '>', came back as idea text and used up the MaxReturnedRunes budget before the real content. Comments are now skipped as a whole, and so are the contents of script, style, noscript and template (case-insensitive; template may nest). Ordinary tags, spacing and entity unescaping are unchanged. Hive-Run: hivecommons#474 Hive-Plan: issue-474 Hive-Spec: issue-474#acceptance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Danathar <Danathar@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Decision needed: @clubanderson should decide which of the two #474 fixes lands — this one (#476, broader edge-case coverage, no issue link) or #475 (hive scanner, Closes #474) — and close the other.
This appears to duplicate #475. Both PRs fix #474 by making StripTags in pkg/intake/intake.go element-aware: HTML comments are skipped as a unit, and the contents of script/style/noscript/template are dropped up to the matching close tag (case-insensitive) or end of input. I read both diffs in full; they only touch pkg/intake/intake.go and pkg/intake/intake_test.go, both green on build-and-test, and they cannot both merge (both rewrite the StripTags loop at intake.go:255).
Verified differences (this PR vs #475):
- Nested
<template>:skipHTMLRegionhere tracks depth fortemplate(intake.gonew lines ~depth++/depth--), soa<template><template>x</template>y</template>b→a b. #475'sskipHTMLElementstops at the first</template>, so the trailingywould leak. Rare in real "Save as HTML" output, but a real behavioural difference. - Empty comments
<!-->/<!--->: this PR searches for-->fromi+2and ends them where a browser does; #475 searches fromi+4and would swallow text until the next-->. - This PR also extends
TestExtractTextFormatswith the exactExtractDocument(".html", …)repro from #474; #475 testsStripTagsonly. - #475 carries
Closes #474in its body; this PR's body is empty and does not reference the issue, so merging it as-is leaves #474 open.
Both implementations are correct for the cases #474 lists (I traced the <a title="<!--"> attribute case and the stray </> cases in both; ordinary tags, spacing and html.UnescapeString are unchanged in both). If this one is preferred, its body needs Closes #474 added. I have not closed anything.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Needs a decision, not a merge:
Head: verdict requires_human @108ab63, 3/4 checks green, 1 pending, DCO yes, soak 0s of 30m0s. How to release it:
Clear the cause and the hive re-evaluates on its next pass; the stage moves to |
|
Needs a decision, not a merge:
Head: verdict requires_human @108ab63, 4/4 checks green, DCO yes, soak 1m0s of 30m0s. How to release it:
Clear the cause and the hive re-evaluates on its next pass; the stage moves to |
|
Reply to the reviewer: the PR body now starts with 🐝 Hive Agent: |
clubanderson
left a comment
There was a problem hiding this comment.
Approved - taking the contributor's version; #475 closes as superseded.
|
LGTM label has been added. DetailsGit tree hash: d375a3c0833511dce47ea6092c29fa1f97c297e9 |
Closes #474.
StripTagsinpkg/intake/intake.goremoved only the<...>tokens and kept the text between them. An uploaded HTML page's inline CSS and JS, and any comment containing>, came back as idea text and used up theMaxReturnedRunesbudget before the real content.What changed:
<!-->,<!--->) end where a browser ends them.script,style,noscriptandtemplateare dropped up to the matching close tag (case-insensitive) or to end of input.templatemay nest.html.UnescapeStringbehave as before.TestExtractTextFormatsnow includes [scanner] intake: StripTags leaks style, script and comment text from uploaded HTML into idea text #474's ownExtractDocument(".html", …)repro, in addition to theStripTagsunit cases.Note: #475 fixes the same issue, and the two cannot both merge. The reviewer compared them in the review on this PR. The maintainer chooses which one lands.
🐝 Hive Agent:
contributor| SHA:108ab63— hive: backend=claude model=claude-opus-5-5 claude=2.1.309 (Claude Code)
🤖 Generated with Claude Code