Sha256: 4279aacafc982f959091583c37775c89193681105ae5072ad193a163913d62f4

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

module Msip
  class AnexosController < ApplicationController
    load_and_authorize_resource class: Msip::Anexo

    def descarga_anexo
      if !params[:id].nil?
        @anexo = Anexo.find(params[:id].to_i)
        ruta = @anexo.adjunto_file_name
        if !ruta.nil?
          # Idea para evitar inyeccion de https://www.ruby-forum.com/topic/124471
          n=sprintf(Msip.ruta_anexos.to_s + "/%d_%s", @anexo.id.to_i, 
                    File.basename(ruta))
          logger.debug "Descargando #{n}"
          send_file n, x_sendfile: true
        else
          redirect_to usuarios_url
        end
      end
    end

    def abre_anexo
      if !params[:id].nil?
        @anexo = Anexo.find(params[:id].to_i)
        ruta = @anexo.adjunto_file_name
        if !ruta.nil?
          # Idea para evitar inyeccion de https://www.ruby-forum.com/topic/124471
          n=sprintf(Msip.ruta_anexos.to_s + "/%d_%s", @anexo.id.to_i, 
                    File.basename(ruta))
          logger.debug "Descargando #{n}"
          send_file n, disposition: :inline
        else
          redirect_to usuarios_url
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
msip-2.2.0.alfa3 app/controllers/msip/anexos_controller.rb
msip-2.2.0.alfa2 app/controllers/msip/anexos_controller.rb
msip-2.2a2 app/controllers/msip/anexos_controller.rb