Only strip the drive name if it begins the string.

This commit is contained in:
Parker Moore 2014-03-27 18:19:35 -04:00
parent bc920f00a2
commit 009e2c200d
2 changed files with 5 additions and 1 deletions

View File

@ -111,7 +111,7 @@ module Jekyll
def self.sanitized_path(base_directory, questionable_path)
clean_path = File.expand_path(questionable_path, fs_root)
clean_path.gsub!(/\w\:\//, '/')
clean_path.gsub!(/\A\w\:\//, '/')
unless clean_path.start_with?(base_directory)
File.join(base_directory, clean_path)
else

View File

@ -10,5 +10,9 @@ class TestPathSanitization < Test::Unit::TestCase
should "strip drive name from path" do
assert_equal "C:/Users/xmr/Desktop/mpc-hc.org/_site", Jekyll.sanitized_path(@source, @dest)
end
should "strip just the initial drive name" do
assert_equal "/tmp/foobar/jail/..c:/..c:/..c:/etc/passwd", Jekyll.sanitized_path("/tmp/foobar/jail", "..c:/..c:/..c:/etc/passwd")
end
end
end