]> source.dussan.org Git - redmine.git/commitdiff
Return 404 if revision URL doesn't exist (#36561).
authorMarius Balteanu <marius.balteanu@zitec.com>
Fri, 18 Feb 2022 08:03:52 +0000 (08:03 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Fri, 18 Feb 2022 08:03:52 +0000 (08:03 +0000)
Patch by Mizuki ISHIKAWA.

git-svn-id: http://svn.redmine.org/redmine/trunk@21413 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/wiki_controller.rb
app/models/wiki_page.rb
test/functional/wiki_controller_test.rb

index 98066a713df9aac629573ddafe9ac5d73886ca40..074031eecb0796a1bf461603adb633da0b14bc24 100644 (file)
@@ -89,7 +89,7 @@ class WikiController < ApplicationController
     end
     @content = @page.content_for_version(params[:version])
     if @content.nil?
-      if User.current.allowed_to?(:edit_wiki_pages, @project) && editable? && !api_request?
+      if params[:version].blank? && User.current.allowed_to?(:edit_wiki_pages, @project) && editable? && !api_request?
         edit
         render :action => 'edit'
       else
index ff1c598eb1da5d39841a89d4e3047e47349bcb17..7c5693ca1e03835cb42e738ca302cfed2aab50b4 100644 (file)
@@ -162,11 +162,7 @@ class WikiPage < ActiveRecord::Base
   end
 
   def content_for_version(version=nil)
-    if content
-      result = content.versions.find_by_version(version.to_i) if version
-      result ||= content
-      result
-    end
+    (content && version) ? content.versions.find_by_version(version.to_i) : content
   end
 
   def diff(version_to=nil, version_from=nil)
index d5758cb09508806b67cd031d84f59fccb14a2bc2..64d0a4e48740fd2822ac2afeee19c160346a9008 100644 (file)
@@ -201,6 +201,12 @@ class WikiControllerTest < Redmine::ControllerTest
     assert_select 'select[name=?] option[value="2"][selected=selected]', 'wiki_page[parent_id]'
   end
 
+  def test_show_unexistent_version_page
+    @request.session[:user_id] = 2
+    get :show, :params => {:project_id => 1, :id => 'CookBook_documentation', :version => 100}
+    assert_response 404
+  end
+
   def test_show_should_not_show_history_without_permission
     Role.anonymous.remove_permission! :view_wiki_edits
     get :show, :params => {:project_id => 1, :id => 'Page with sections', :version => 2}