Claude Sonnet 5.5 · Balanced
enhance-embed-url-handling-and-validation-system-discourse-cursor
Discourse · Ruby · M · 100–299 lines · 6 files
The normal review, with one generalist agent. Judge: Claude Haiku 5.5.
- Gold bugs found
- 2 of 12
- Comments published
- 4
- Comments matching a bug
- 2
- Comments not matching
- 2
- Cost of this PR
- $0.668
Published comments (4)
Raw HTML posts skip sanitization, allowing stored XSS from imported content — Imported feed content such as `<script>` tags or event-handler attributes reaches the forum unsanitized, which makes stored XSS possible. Sanitize `raw` in the `raw_html` branch of `Post#cook`, or before storing it in `TopicEmbed.import`.
Unescaped URL interpolated into raw HTML link allows markup injection — The `url` can contain single quotes or angle brackets, so a crafted feed link can break out of the `href` attribute and inject markup. Escape it with `ERB::Util.html_escape` for both the href and the text, and anchor the check with `\A`.
Embed is created for an unsaved post when PostCreator fails — `PostCreator#create` returns an unsaved post on failure, so `TopicEmbed.create!` raises on a nil `post_id` and aborts the whole `PollFeed` run. Check `post.persisted?` and `creator.errors.blank?` before creating the embed.
Nil content on feed item raises NoMethodError and aborts the poll loop — A feed item with no `content` makes `i.content.scrub` raise `NoMethodError`, which stops the poll and skips all later items. Fall back to `i.description`, skip blank items, and rescue per-item errors.