Commit 3f491f98 authored by gubala's avatar gubala

better handling of paths

parent 7311393f
......@@ -54,8 +54,7 @@ class ApplicationController < ActionController::Base
@path = params[:path]
@path.gsub!("gsiftp:/login01.prometheus.cyfronet.pl/", "prometheus/")
@path = "/#{@path}" unless @path.start_with?('/')
@unescaped_path = URI.unescape(@path)
@path = URI.escape @path
@path = URI.escape(URI.unescape(@path))
end
def set_gftp_server
......@@ -64,11 +63,6 @@ class ApplicationController < ActionController::Base
Plgdata::Application.config.prometheus_gridftp_host +
"/#{@path.gsub!('prometheus/', '')}"
end
if @unescaped_path.start_with?('/prometheus/') || @unescaped_path.start_with?('prometheus/')
@unescaped_path = "gsiftp://" +
Plgdata::Application.config.prometheus_gridftp_host +
"/#{@unescaped_path.gsub!('prometheus/', '')}"
end
end
def sanitize_filename(filename)
......
class FilesController < ApplicationController
skip_before_filter :authenticate_user!, only: [:download, :upload, :remove]
before_filter :sanitize_path
before_filter :set_gftp_server
before_filter :restrict_api_access, only: [:download, :upload, :remove]
......@@ -33,16 +34,14 @@ class FilesController < ApplicationController
target_filename = sanitize_filename file.original_filename
if target_filename.present?
begin
logger.debug "Escaped path: #{@path}"
logger.debug "UNEscaped path: #{@unescaped_path}"
if is_blob
offset = request.headers['Content-Range'].split(' ')[1].to_i
data = file.read
logger.info "Executing PARTIAL put for [#{target_filename}], offset #{offset}, data size #{data.size}."
GFTP::PartialPut.new(data.size).partial_put @unescaped_path + '/' + target_filename, @proxy, data, offset
logger.info "Executing PARTIAL put for [#{target_filename}], path [#{@path}], offset #{offset}, data size #{data.size}."
GFTP::PartialPut.new(data.size).partial_put @path + '/' + target_filename, @proxy, data, offset
else
logger.info "Executing NORMAL put for [#{target_filename}]."
GFTP::Put.new.put @unescaped_path + '/' + target_filename, @proxy do |buf_size|
logger.info "Executing NORMAL put for [#{target_filename}], path [#{@path}]."
GFTP::Put.new.put @path + '/' + target_filename, @proxy do |buf_size|
[ file.read(buf_size) || '', file.eof? ]
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment