Merge pull request #2065 from jekyll/fix-windows-root-system-thingy
This commit is contained in:
commit
3072a16b86
|
@ -102,4 +102,24 @@ module Jekyll
|
||||||
def self.logger
|
def self.logger
|
||||||
@logger ||= Stevenson.new
|
@logger ||= Stevenson.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Public: File system root
|
||||||
|
#
|
||||||
|
# Returns the root of the filesystem as a Pathname
|
||||||
|
def self.fs_root
|
||||||
|
@fs_root ||= traverse_up(Pathname.new(Dir.pwd))
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.sanitized_path(base_directory, questionable_path)
|
||||||
|
clean_path = File.expand_path(questionable_path, fs_root)
|
||||||
|
clean_path.sub(/\A[\w]:\\\\/, '')
|
||||||
|
File.join(base_directory, clean_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def self.traverse_up(pathname)
|
||||||
|
return pathname if pathname.parent.eql?(pathname)
|
||||||
|
traverse_up(pathname.parent)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,13 +38,11 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
def layout_directory_inside_source
|
def layout_directory_inside_source
|
||||||
# TODO: Fix for Windows
|
Jekyll.sanitized_path(site.source, site.config['layouts'])
|
||||||
File.join(site.source, File.expand_path(site.config['layouts'], "/"))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def layout_directory_in_cwd
|
def layout_directory_in_cwd
|
||||||
# TODO: Fix on Windows
|
dir = Jekyll.sanitized_path(Dir.pwd, site.config['layouts'])
|
||||||
dir = File.join(Dir.pwd, File.expand_path(site.config['layouts'], '/'))
|
|
||||||
if File.directory?(dir)
|
if File.directory?(dir)
|
||||||
dir
|
dir
|
||||||
else
|
else
|
||||||
|
|
|
@ -135,7 +135,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns the destination file path String.
|
# Returns the destination file path String.
|
||||||
def destination(dest)
|
def destination(dest)
|
||||||
path = File.join(dest, File.expand_path(url, "/"))
|
path = Jekyll.sanitized_path(dest, url)
|
||||||
path = File.join(path, "index.html") if url =~ /\/$/
|
path = File.join(path, "index.html") if url =~ /\/$/
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
@ -156,7 +156,7 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
def uses_relative_permalinks
|
def uses_relative_permalinks
|
||||||
permalink && @dir != "" && site.config['relative_permalinks']
|
permalink && !@dir.empty? && site.config['relative_permalinks']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -260,7 +260,7 @@ module Jekyll
|
||||||
# Returns destination file path String.
|
# Returns destination file path String.
|
||||||
def destination(dest)
|
def destination(dest)
|
||||||
# The url needs to be unescaped in order to preserve the correct filename
|
# The url needs to be unescaped in order to preserve the correct filename
|
||||||
path = File.join(dest, File.expand_path(CGI.unescape(url), "/"))
|
path = Jekyll.sanitized_path(dest, CGI.unescape(url))
|
||||||
path = File.join(path, "index.html") if path[/\.html$/].nil?
|
path = File.join(path, "index.html") if path[/\.html$/].nil?
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue