GPT-6.1 Sol · 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
- 3 of 12
- Comments published
- 5
- Comments matching a bug
- 3
- Comments not matching
- 2
- Cost of this PR
- $0.794
Published comments (5)
Unsanitized feed HTML allows stored XSS in imported posts and revisions — Feed authors can execute JavaScript in the forum’s origin because `absolutize_urls` preserves scripts and event handlers, while `Post.cook` returns `raw_html` verbatim. Sanitize imported HTML with explicit tag, attribute, and URL-scheme allowlists before storing posts or revisions.
Invalid Ruby in embed template prevents existing topics from rendering — Existing embedded topics fail to display comments because the conditionless `if` makes the template invalid Ruby. Replace `<%- end if %>` with `<%- end %>`.
Feed polling aborts on RSS entries without a content field — Valid RSS entries can lack `i.content`, causing `scrub` to abort polling before later entries are imported. Fall back to `i.content_encoded` or `i.description` before scrubbing, and explicitly skip entries with no body.
Imported URLs mishandle protocol-relative and path-relative references — Imported links and images break because `prefix` concatenation misroutes protocol-relative URLs and leaves path-relative URLs unresolved. Resolve `href` and `src` against the full article URL using `URI.join` instead.
Cold article requests repeatedly download and process the entire feed — Concurrent uncached article requests each invoke `Jobs::PollFeed`, multiplying full-feed downloads and per-entry database work despite the hourly schedule. Add a feed-wide cache or lock with a polling interval so different article URLs reuse a recent poll.