MiniMax M3 · 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.127
Published comments (4)
raw post.cooked renders unsanitized HTML in embed iframe — Embedding unsanitized `post.cooked` from `Post#cook` allows `<script>` injection (ruby-readability preserves event handlers), so a malicious embeddable_host can run JS in Discourse's origin and steal session cookies. Sanitize raw_html posts through PrettyText or escape here and only unescape known-safe subtrees, using `post.cookedHtml`.
poll_feed loop aborts batch on any per-item error — Any per-item failure in `poll_feed`'s `rss.items.each` loop (e.g. `i.content.scrub` raising `NoMethodError`) drops every remaining item for that hour because `retry: false` swallows the abort. Wrap each iteration in `begin/rescue`, log the exception, and also rescue `Errno::ECONNREFUSED`/`SocketError` around `open()`.
PollFeed runs synchronously inside RetrieveTopic worker — Enqueue it instead via `Jobs.enqueue(:poll_feed)` so the retriever only schedules the work and returns.
Use URI.open instead of Kernel#open to avoid shell evaluation — Using `Kernel#open` to fetch the feed URL retains shell semantics and executes strings starting with `|`, including any value later typed into `feed_polling_url` in the admin UI. Switch to `URI.open(SiteSetting.feed_polling_url)` so the input is unambiguously treated as a URI.