diff options
-rw-r--r-- | app/controllers/account_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/application.rb | 6 | ||||
-rw-r--r-- | app/controllers/documents_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/issue_categories_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/issues_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/members_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/news_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/projects_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/queries_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/reports_controller.rb | 10 | ||||
-rw-r--r-- | app/controllers/repositories_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/versions_controller.rb | 5 | ||||
-rw-r--r-- | app/views/common/404.rhtml | 4 |
13 files changed, 48 insertions, 21 deletions
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index ffd2419b3..fb775d196 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -28,6 +28,8 @@ class AccountController < ApplicationController def show
@user = User.find(params[:id])
@custom_values = @user.custom_values.find(:all, :include => :custom_field)
+ rescue ActiveRecord::RecordNotFound
+ render_404
end
# Login request and validation
diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 516285d77..da01e09c8 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -103,6 +103,12 @@ class ApplicationController < ActionController::Base redirect_to_url session[:return_to] session[:return_to] = nil end + end
+
+ def render_404
+ @html_title = "404"
+ render :template => "common/404", :layout => true, :status => 404
+ return false
end # qvalues http header parser
diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 3cc8662ea..5ff3583d9 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -41,8 +41,7 @@ class DocumentsController < ApplicationController @attachment.increment_download
send_file @attachment.diskfile, :filename => @attachment.filename
rescue
- flash.now[:notice] = l(:notice_file_not_found)
- render :text => "", :layout => true, :status => 404
+ render_404
end
def add_attachment
@@ -62,5 +61,7 @@ private def find_project
@document = Document.find(params[:id])
@project = @document.project
+ rescue ActiveRecord::RecordNotFound
+ render_404
end end diff --git a/app/controllers/issue_categories_controller.rb b/app/controllers/issue_categories_controller.rb index 965a15e78..7f2e4cbe2 100644 --- a/app/controllers/issue_categories_controller.rb +++ b/app/controllers/issue_categories_controller.rb @@ -35,8 +35,10 @@ class IssueCategoriesController < ApplicationController end
private
- def find_project
+ def find_project
@category = IssueCategory.find(params[:id])
- @project = @category.project
- end
+ @project = @category.project
+ rescue ActiveRecord::RecordNotFound
+ render_404
+ end
end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 7a3679386..d37333e37 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -132,8 +132,7 @@ class IssuesController < ApplicationController @attachment = @issue.attachments.find(params[:attachment_id])
send_file @attachment.diskfile, :filename => @attachment.filename
rescue
- flash.now[:notice] = l(:notice_file_not_found)
- render :text => "", :layout => true, :status => 404
+ render_404
end
private
@@ -141,5 +140,7 @@ private @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
@project = @issue.project
@html_title = "#{@project.name} - #{@issue.tracker.name} ##{@issue.id}"
+ rescue ActiveRecord::RecordNotFound
+ render_404
end end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index be3f717d1..f595f2cf6 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -33,9 +33,11 @@ class MembersController < ApplicationController end
private
- def find_project
+ def find_project
@member = Member.find(params[:id])
- @project = @member.project
- end + @project = @member.project
+ rescue ActiveRecord::RecordNotFound
+ render_404
+ end end diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 544b6eb8d..0f2ae85c6 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -51,8 +51,10 @@ class NewsController < ApplicationController end
private
- def find_project
+ def find_project
@news = News.find(params[:id])
- @project = @news.project
- end + @project = @news.project
+ rescue ActiveRecord::RecordNotFound
+ render_404
+ end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 78a1e4660..53293340e 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -500,8 +500,8 @@ private def find_project
@project = Project.find(params[:id])
@html_title = @project.name
- rescue - redirect_to :action => 'list'
+ rescue ActiveRecord::RecordNotFound + render_404
end
# Retrieve query from session or build a new query
diff --git a/app/controllers/queries_controller.rb b/app/controllers/queries_controller.rb index 4bdd8aaa2..7f7f01fd3 100644 --- a/app/controllers/queries_controller.rb +++ b/app/controllers/queries_controller.rb @@ -45,5 +45,7 @@ private @project = @query.project # check if user is allowed to manage queries (same permission as add_query) authorize('projects', 'add_query') + rescue ActiveRecord::RecordNotFound + render_404 end end diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index f493f5c60..b825a8ac6 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -98,10 +98,12 @@ class ReportsController < ApplicationController end
private
- # Find project of id params[:id]
- def find_project
- @project = Project.find(params[:id])
- end
+ # Find project of id params[:id]
+ def find_project
+ @project = Project.find(params[:id])
+ rescue ActiveRecord::RecordNotFound
+ render_404
+ end
def issues_by_tracker
@issues_by_tracker ||=
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 9dbbfebd9..a10dfcc22 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -63,6 +63,8 @@ private @path = params[:path].squeeze('/').gsub(/^\//, '') if params[:path] @path ||= '' @rev = params[:rev].to_i if params[:rev] and params[:rev].to_i > 0 + rescue ActiveRecord::RecordNotFound + render_404 end def show_error diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index d1980d74f..5c2dcc7f6 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -39,8 +39,7 @@ class VersionsController < ApplicationController @attachment.increment_download
send_file @attachment.diskfile, :filename => @attachment.filename
rescue
- flash.now[:notice] = l(:notice_file_not_found)
- render :text => "", :layout => true, :status => 404
+ render_404
end
def destroy_file
@@ -53,5 +52,7 @@ private def find_project
@version = Version.find(params[:id])
@project = @version.project
+ rescue ActiveRecord::RecordNotFound
+ render_404
end end diff --git a/app/views/common/404.rhtml b/app/views/common/404.rhtml new file mode 100644 index 000000000..a81eeba02 --- /dev/null +++ b/app/views/common/404.rhtml @@ -0,0 +1,4 @@ +<h2>404</h2>
+
+<p><%= l(:notice_file_not_found) %></p>
+<p><a href="javascript:history.back()">Back</a></p>
|