Return HTTP404 to requests pointing to a non-existant web name

This commit is contained in:
Alexey Verkhovsky 2005-03-25 23:40:03 +00:00
parent 1bb4747a0f
commit 759fbda8a0
3 changed files with 13 additions and 1 deletions

View file

@ -40,7 +40,13 @@ class ApplicationController < ActionController::Base
@action_name = @params['action'] || 'index'
@web_name = @params['web']
@wiki = wiki
@web = @wiki.webs[@web_name] unless @web_name.nil?
if @web_name
@web = @wiki.webs[@web_name]
if @web.nil?
render_text "Unknown web '#{@web_name}'", '404 Not Found'
return false
end
end
@page_name = @file_name = @params['id']
@page = @wiki.read_page(@web_name, @page_name) unless @page_name.nil?
@author = cookies['author'] || 'AnonymousCoward'

View file

@ -23,4 +23,9 @@ class ApplicationTest < Test::Unit::TestCase
assert_equal 'text/html; charset=UTF-8', r.headers['Content-Type']
end
def test_connect_to_model_unknown_wiki
r = process('show', 'web' => 'unknown_wiki', 'id' => 'HomePage')
assert_equal 404, r.response_code
end
end

View file

@ -166,6 +166,7 @@ class WikiControllerTest < Test::Unit::TestCase
end
def test_index_multiple_webs_web_explicit
@wiki.create_web('Test Wiki 2', 'wiki2')
process('index', 'web' => 'wiki2')
assert_redirected_to :web => 'wiki2', :action => 'show', :id => 'HomePage'
end