Rubocop fixes for test/test_path_sanitization.rb
This commit is contained in:
parent
c76b458dd5
commit
df01b6825e
|
@ -77,7 +77,6 @@ AllCops:
|
|||
- test/test_kramdown.rb
|
||||
- test/test_liquid_renderer.rb
|
||||
- test/test_page.rb
|
||||
- test/test_path_sanitization.rb
|
||||
- test/test_plugin_manager.rb
|
||||
- test/test_rdiscount.rb
|
||||
- test/test_redcarpet.rb
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'helper'
|
||||
require "helper"
|
||||
|
||||
class TestPathSanitization < JekyllUnitTest
|
||||
context "on Windows with absolute source" do
|
||||
|
@ -8,20 +8,24 @@ class TestPathSanitization < JekyllUnitTest
|
|||
allow(Dir).to receive(:pwd).and_return("C:/Users/xmr/Desktop/mpc-hc.org")
|
||||
end
|
||||
should "strip drive name from path" do
|
||||
assert_equal "C:/Users/xmr/Desktop/mpc-hc.org/_site", Jekyll.sanitized_path(@source, @dest)
|
||||
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")
|
||||
assert_equal "/tmp/foobar/jail/..c:/..c:/..c:/etc/passwd",
|
||||
Jekyll.sanitized_path("/tmp/foobar/jail", "..c:/..c:/..c:/etc/passwd")
|
||||
end
|
||||
end
|
||||
|
||||
should "escape tilde" do
|
||||
assert_equal source_dir("~hi.txt"), Jekyll.sanitized_path(source_dir, "~hi.txt")
|
||||
assert_equal source_dir("files", "~hi.txt"), Jekyll.sanitized_path(source_dir, "files/../files/~hi.txt")
|
||||
assert_equal source_dir("files", "~hi.txt"),
|
||||
Jekyll.sanitized_path(source_dir, "files/../files/~hi.txt")
|
||||
end
|
||||
|
||||
should "remove path traversals" do
|
||||
assert_equal source_dir("files", "hi.txt"), Jekyll.sanitized_path(source_dir, "f./../../../../../../files/hi.txt")
|
||||
assert_equal source_dir("files", "hi.txt"),
|
||||
Jekyll.sanitized_path(source_dir, "f./../../../../../../files/hi.txt")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue