mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[local|storage] CGI.escape file names
This commit is contained in:
parent
a063173ba9
commit
21cd346b4d
2 changed files with 17 additions and 3 deletions
|
@ -65,7 +65,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def path
|
def path
|
||||||
connection.path_to(::File.join(directory.key, key))
|
connection.path_to(::File.join(directory.key, CGI.escape(key)))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Fog
|
||||||
path = file_path(key)
|
path = file_path(key)
|
||||||
{
|
{
|
||||||
:content_length => ::File.size(path),
|
:content_length => ::File.size(path),
|
||||||
:key => key,
|
:key => CGI.unescape(key),
|
||||||
:last_modified => ::File.mtime(path)
|
:last_modified => ::File.mtime(path)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -32,7 +32,7 @@ module Fog
|
||||||
|
|
||||||
def get(key, &block)
|
def get(key, &block)
|
||||||
requires :directory
|
requires :directory
|
||||||
path = file_path(key)
|
path = file_path(CGI.escape(key))
|
||||||
if ::File.exists?(path)
|
if ::File.exists?(path)
|
||||||
data = {
|
data = {
|
||||||
:content_length => ::File.size(path),
|
:content_length => ::File.size(path),
|
||||||
|
@ -53,6 +53,20 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def head(key)
|
||||||
|
requires :directory
|
||||||
|
path = file_path(CGI.escape(key))
|
||||||
|
if ::File.exists?(path)
|
||||||
|
new({
|
||||||
|
:content_length => ::File.size(path),
|
||||||
|
:key => key,
|
||||||
|
:last_modified => ::File.mtime(path)
|
||||||
|
})
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def new(attributes = {})
|
def new(attributes = {})
|
||||||
requires :directory
|
requires :directory
|
||||||
super({ :directory => directory }.merge!(attributes))
|
super({ :directory => directory }.merge!(attributes))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue