Enhance embed URL handling and validation system#7
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| <%= link_to(I18n.t('embed.title'), @topic_view.topic.url, class: 'button', target: '_blank') %> | ||
| <%- else %> | ||
| <%= link_to(I18n.t('embed.start_discussion'), @topic_view.topic.url, class: 'button', target: '_blank') %> | ||
| <%- end if %> |
There was a problem hiding this comment.
Fix invalid ERB block terminator
The new embed view uses <%- end if %> to close the header conditional (line 6). end if is not valid Ruby/ERB syntax, so Rails raises a template compilation error the first time /embed/best is rendered and no HTML is returned. This means the entire embed feature crashes before it can show any posts. Replace the terminator with a normal <%- end %> so the template can render.
Useful? React with 👍 / 👎.
| url = i.link | ||
| url = i.id if url.blank? || url !~ /^https?\:\/\// | ||
|
|
||
| content = CGI.unescapeHTML(i.content.scrub) | ||
| TopicEmbed.import(user, url, i.title, content) |
There was a problem hiding this comment.
Handle feeds without content nodes
In Jobs::PollFeed, every item is assumed to have a content field and the code calls i.content.scrub unconditionally. Standard RSS 2.0 feeds only expose a <description> field, so i.content is nil and this line raises NoMethodError: undefined method scrub' for nil:NilClassbefore any topic can be imported. As a result, feed polling fails for the majority of feeds. Guard againstnil(fall back toi.description/i.summaryor skip the entry) before callingscrub` so the job can process real-world feeds.
Useful? React with 👍 / 👎.
Test 4
Replicated from ai-code-review-evaluation/discourse-cursor#4