From c443dddeeaec6d3921a15c28cbfe54af611824f8 Mon Sep 17 00:00:00 2001 From: chiu Date: Wed, 4 Aug 2021 20:17:56 +0800 Subject: [PATCH] fix error --- app/controllers/announcements_controller.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index 40c3235..ec05778 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -497,11 +497,11 @@ class AnnouncementsController < ApplicationController end def get_file @url = request.path - if @url.match(/\/\.\./) + begin + if @url.match(/\/\.\./) render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found, :content_type => 'text/html' return - end - begin + end file = BulletinFile.find(params[:id]) if File.basename(file.file.path) != URI.decode(params[:f_name]) render :file => "#{Rails.root}/app/views/errors/403.html", :layout => false, :status => :not_found, :content_type => 'text/html' @@ -517,15 +517,19 @@ class AnnouncementsController < ApplicationController else if (current_site.accessibility_mode rescue false) render "archives/redirect_to_file.html",:layout=>false + return else send_file(@path) + return end end else render :file => "#{Rails.root}/app/views/errors/403.html", :layout => false, :status => :not_found, :content_type => 'text/html' + return end rescue render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found, :content_type => 'text/html' + return end end def show_local_announcement(uid, is_preview)