Test case for issue #5276, where Jekyll.sanitized_path strips base path incorrectly if file path has matching prefix
This commit is contained in:
parent
7892c5e1f3
commit
0d8796fbe6
|
|
@ -28,4 +28,22 @@ class TestPathSanitization < JekyllUnitTest
|
||||||
assert_equal source_dir("files", "hi.txt"),
|
assert_equal source_dir("files", "hi.txt"),
|
||||||
Jekyll.sanitized_path(source_dir, "f./../../../../../../files/hi.txt")
|
Jekyll.sanitized_path(source_dir, "f./../../../../../../files/hi.txt")
|
||||||
end
|
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
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue