FIX: Render a 404 error on a bad redirect in list controller

When bad data is provided in the URI for redirecting to a category,
Rails raises an `ActionController::Redirecting::UnsafeRedirectError`
error, leading to a 500 error.

This patch catches the exception to render a 404 instead.
This commit is contained in:
Loïc Guitaut
2024-06-27 15:51:45 +02:00
committed by Loïc Guitaut
parent a442eeb0f4
commit 232503b3df
2 changed files with 18 additions and 0 deletions

View File

@ -49,6 +49,10 @@ class ListController < ApplicationController
:filter,
].flatten
rescue_from ActionController::Redirecting::UnsafeRedirectError do
raise Discourse::NotFound
end
# Create our filters
Discourse.filters.each do |filter|
define_method(filter) do |options = nil|