Skip to content

Commit

Permalink
Catch invalid node on wiki revision request (#8729)
Browse files Browse the repository at this point in the history
fixes #8728
  • Loading branch information
jywarren authored Nov 10, 2020
1 parent 5e40287 commit 5c23901
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions app/controllers/wiki_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,21 +288,25 @@ def revisions

def revision
@node = Node.find_wiki(params[:id])
@tags = @node.tags
@tagnames = @tags.collect(&:name)
@unpaginated = true
@is_revision = true
set_sidebar :tags, @tagnames, videos: true
@revision = Revision.find_by_nid_and_vid(@node.id, params[:vid])
if @revision.nil?
flash[:error] = I18n.t('wiki_controller.revision_not_found')
redirect_to action: 'revisions'
elsif @revision.status == 1 || current_user&.can_moderate?
@title = I18n.t('wiki_controller.revisions_for', title: @revision.title).html_safe
render template: 'wiki/show'
if @node
@tags = @node.tags
@tagnames = @tags.collect(&:name)
@unpaginated = true
@is_revision = true
set_sidebar :tags, @tagnames, videos: true
@revision = Revision.find_by_nid_and_vid(@node.id, params[:vid])
if @revision.nil?
flash[:error] = I18n.t('wiki_controller.revision_not_found')
redirect_to action: 'revisions'
elsif @revision.status == 1 || current_user&.can_moderate?
@title = I18n.t('wiki_controller.revisions_for', title: @revision.title).html_safe
render template: 'wiki/show'
else
flash[:error] = I18n.t('wiki_controller.revision_has_been_moderated').html_safe
redirect_to @node.path
end
else
flash[:error] = I18n.t('wiki_controller.revision_has_been_moderated').html_safe
redirect_to @node.path
flash[:error] = I18n.t('wiki_controller.invalid_wiki_page')
end
end

Expand Down

0 comments on commit 5c23901

Please sign in to comment.