Skip to content

A platform for community discussion. Free, open, simple.

FIX: Return a 404 when a sitemap request doesn't have a format (#16506)

Roman Rizzi48417b59d649
diff --git a/config/routes.rb b/config/routes.rb
index d88dea760f2..3cf5d7ef97f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -26,7 +26,7 @@ Discourse::Application.routes.draw do
post "webhooks/sendgrid" => "webhooks#sendgrid"
post "webhooks/sparkpost" => "webhooks#sparkpost"
- scope path: nil, constraints: { format: :xml } do
+ scope path: nil, format: true, constraints: { format: :xml } do
resources :sitemap, only: [:index]
get "/sitemap_:page" => "sitemap#page", page: /[1-9][0-9]*/
get "/sitemap_recent" => "sitemap#recent"
diff --git a/spec/requests/sitemap_controller_spec.rb b/spec/requests/sitemap_controller_spec.rb
index 682d08549aa..619a1383f9a 100644
--- a/spec/requests/sitemap_controller_spec.rb
+++ b/spec/requests/sitemap_controller_spec.rb
@@ -12,6 +12,12 @@ describe SitemapController do
expect(response.status).to eq(404)
end
+
+ it "returns a 404 if the request does't have a format" do
+ get '/news'
+
+ expect(response.status).to eq(404)
+ end
end
describe '#index' do