#95

Fix the Rails template leftover and sanitize preview links

Openashcoftwants to merge intofrom

This PR was created by an AI agent (OpenHands) on behalf of the user.

What changed

Rails template leftover

frontend/frontend/templates/base.html still contained:

<div class="<%= (user_signed_in? && content_for?(:side_menu)) ? 'span9' : 'span12' %>">

It now renders a plain Django layout:

<div class="span12">

The undefined user_signed_in check above it was replaced with user.is_authenticated. No template in the repository fills {% block side_menu %}, so span12 is the correct class.

Preview links

frontend/frontend/templates/frontend/preview.html now builds item headings with a safeUrl helper:

  • only http: and https: links become anchors;
  • file:, javascript:, data: and other schemes are shown as plain text;
  • the title is inserted with .text() instead of string concatenation.

That prevents the Security Error: Content at ... may not load or link to file:/// message when a feed item has a local link.

Tests

Added to tests/test_reader_django.py:

  • the index page contains no <%= or content_for? markup;
  • the preview page uses safeUrl(item.link).

Note on the XML error

The XML parsing error comes from the feed response itself, not from the page. If /feed/2?sanitize=Y is malformed or returns an HTML error page, the preview script will still show its failure message. This PR fixes the page markup and the file:// link handling; the feed source still needs to be valid XML.

@ashcoft can click here to continue refining the PR

Summary by Sourcery

Clean up the Django templates and safely render feed preview links.

Bug Fixes:

  • Remove leftover Rails template syntax from the Django base layout and use the correct authentication check.
  • Prevent unsafe or local preview links from being rendered as anchors while preserving valid HTTP and HTTPS links.
  • Avoid injecting feed item titles into preview markup as raw HTML.

Tests:

  • Add coverage ensuring rendered index pages contain no Rails template markup and preview pages use safe URL handling.

Summary by cubic

Removes leftover Rails/ERB markup from the Django base template and stops the feed preview from turning non-HTTP links into clickable anchors.

  • Replaces the undefined user_signed_in check with user.is_authenticated and always renders the span12 class.
  • Preview item titles are set with .text() and only http:/https: links become anchors; other schemes render as plain text.
  • Adds regression tests for the template markup and preview link handling.

Written for commit 6193558435c059ca7ae6d7d5110ce7f00cd728d8. Summary will update on new commits.


This change is 

Confidence Score: 4/5

The PR appears safe to merge, with a non-blocking gap in the preview test.

Findings

  1.  Test misses broken link checks ▶
Fix with agent prompt
### Issue 1
tests/test_reader_django.py:101
`test_preview_page_only_links_http_urls` only checks that the page contains `safeUrl(item.link)`. It still passes if `safeUrl` returns every input unchanged or rejects every link. Add a JavaScript test that renders feed items and checks that HTTP(S) links remain clickable, blocked schemes become plain text, and HTML in titles stays text.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Removes Rails markup from the shared Django layout and makes preview headings safer.

  • Shared pages use Django login checks and a plain content column.
  • Feed preview headings link only to web addresses.

Reviews (1) · Last reviewed commit: "fix: remove Rails template markup and sa..." · Reviewed by Greptile

Activity

33
coderabbitai[bot]2h ago

WARNING

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 26 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 762556ea-9b0d-4a46-82eb-a18a9a811535
Commits

Reviewing files that changed from the base of the PR and between f14fec45bbc1a2a0c23bbca482b492e3adbcee5f and 200496cc63312dcff2c4af71cbdf109700f907b1.

Files selected for processing: 5

  • frontend/frontend/assets/frontend/js/preview.js
  • frontend/frontend/templates/base.html
  • frontend/frontend/templates/frontend/preview.html
  • tests/js/preview.test.js
  • tests/test_reader_django.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

sourcery-ai[bot]2h ago

Reviewer's Guide

Implementation

Extract preview URL validation and DOM rendering into a reusable module that permits only HTTP(S) links and inserts titles and descriptions as text.

  • frontend/frontend/assets/frontend/js/preview.js L1-65

UI

Load the safe preview renderer and replace inline HTML construction with a call to it, while retaining the preview page’s existing feed flow.

  • frontend/frontend/templates/frontend/preview.html L30, L39

Remove the leftover Rails markup from the shared layout, use Django’s authentication check, and render the content at full width.

  • frontend/frontend/templates/base.html L77-80

Tests

Add Node tests for allowed and blocked URLs, text-only rendering, and preview item handling.

  • tests/js/preview.test.js L1-82

Add Django regression checks for the removed Rails markup and preview renderer integration.

  • tests/test_reader_django.py L85-102

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an issue from a review comment by replying to it. You can also reply to a review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull request title to generate a title at any time. You can also comment @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment @sourcery-ai summary on the pull request to (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

snyk-io[bot]2h ago

:white_check_mark: Snyk checks have passed. No issues have been found so far.

StatusScan Engine Critical High Medium LowTotal (0)
:white_check_mark:Open Source Security0000 0 issues

:computer: Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

codacy-production[bot]2h ago

Up to standards :white_check_mark:

🟢 Issues 0 issues

Results: 0 new issues

View in Codacy

🟢 Metrics 19 complexity · 0 duplication

MetricResults
Complexity19
Duplication0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer TIP This summary will be updated as you push new changes.

greptile-apps[bot]reviewed2h ago
greptile-apps[bot]reviewed2h ago
sourcery-ai[bot]2h ago

Sorry @ashcoft, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 hour and 47 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

mergify[bot]2h ago

Queue requested — the merge queue status continues in this comment ↓.

devin-ai-integration[bot]reviewed2h ago
devin-ai-integration[bot]reviewed2h ago
devin-ai-integration[bot]2h ago

NOTE

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 1 potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

kilo-code-bot[bot]reviewed2h ago
devin-ai-integration[bot]reviewed2h ago
devin-ai-integration[bot]reviewed2h ago
devin-ai-integration[bot]reviewed2h ago
devin-ai-integration[bot]reviewed2h ago
devin-ai-integration[bot]2h ago

Devin Review found 1 new potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

greptile-apps[bot]reviewed2h ago
greptile-apps[bot]reviewed2h ago
kilo-code-bot[bot]reviewed2h ago
kilo-code-bot[bot]reviewed2h ago
mergify[bot]2h ago

✅ Merged into main as 187e509 at 06:01 UTC

1 min in the queue, less than a minute of it CI.

So far

  • ✅ Entered the queue Sun 22 Nov, 06:01 · rule default · triggered by @ashcoft with the merge queue checkbox
  • ✅ Passed · draft #97
  • ✅ Merged 06:01 · 187e509

Times in UTC · dashboard · how the merge queue works