Test case for issue #5276, where Jekyll.sanitized_path strips base path incorrectly if file path has matching prefix

This commit is contained in:
Heng, K. (Stephen) 2016-08-26 11:20:03 +08:00
parent 7892c5e1f3
commit 0d8796fbe6
1 changed files with 18 additions and 0 deletions

View File

@ -28,4 +28,22 @@ class TestPathSanitization < JekyllUnitTest
assert_equal source_dir("files", "hi.txt"),
Jekyll.sanitized_path(source_dir, "f./../../../../../../files/hi.txt")
end
context "on Windows with file path has matching prefix" do
setup do
@base_path = "D:/site"
@file_path = "D:/sitemap.xml"
allow(Dir).to receive(:pwd).and_return("D:/")
end
should "not strip base path" do
assert_equal "D:/site/sitemap.xml",
Jekyll.sanitized_path(@base_path, @file_path)
end
end
should "not strip base path if file path has matching prefix" do
assert_equal "/site/sitemap.xml",
Jekyll.sanitized_path("/site", "sitemap.xml")
end
end