From c73db9ff5d482c592a49675032c650f1294bba62 Mon Sep 17 00:00:00 2001 From: Alexey Verkhovsky Date: Sat, 26 Mar 2005 05:37:04 +0000 Subject: [PATCH] Calls to show with unspecified page name cause HTTP 404, not HTTP 500 --- app/controllers/wiki_controller.rb | 6 +++++- test/functional/wiki_controller_test.rb | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 3651aa1a..184e8d56 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -207,7 +207,11 @@ class WikiController < ApplicationController end end else - redirect_to :web => @web_name, :action => 'new', :id => CGI.escape(@page_name) + if not @page_name.nil? and not @page_name.empty? + redirect_to :web => @web_name, :action => 'new', :id => CGI.escape(@page_name) + else + render_text 'Page name is not specified', '404 Not Found' + end end end diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 93bdb6d4..4e641b93 100755 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -552,6 +552,14 @@ class WikiControllerTest < Test::Unit::TestCase assert_redirected_to :web => 'wiki1', :action => 'new', :id => 'UnknownPage' end + def test_show_no_page + r = process('show', 'id' => '', 'web' => 'wiki1') + assert_equal 404, r.response_code + + r = process('show', 'web' => 'wiki1') + assert_equal 404, r.response_code + end + def test_tex r = process('tex', 'web' => 'wiki1', 'id' => 'HomePage')