summaryrefslogtreecommitdiff
path: root/test/paths_test.rb
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2014-07-30 19:30:55 -0600
committerDan Allen <dan.j.allen@gmail.com>2014-07-30 19:36:05 -0600
commit36a33626251d7ddd05f43f7aa73d31bfe8b2b8c1 (patch)
treee6b53607aecb4a0912a6c26f5d84345d2382aa34 /test/paths_test.rb
parentdd141cfd0fc63b28f42707b57822f739881dd066 (diff)
resolves #690 resolve relative paths relative to base_dir in unsafe mode
Diffstat (limited to 'test/paths_test.rb')
-rw-r--r--test/paths_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/paths_test.rb b/test/paths_test.rb
index ea7b0a5b..1503d30d 100644
--- a/test/paths_test.rb
+++ b/test/paths_test.rb
@@ -200,6 +200,21 @@ context 'Path Resolver' do
assert_equal "#{JAIL}/part1/chapter1/section1.adoc", filename
assert_equal 'part1/chapter1/section1.adoc', @resolver.relative_path(filename, JAIL)
end
+
+ test 'should resolve relative path relative to base dir in unsafe mode' do
+ base_dir = fixture_path 'base'
+ doc = empty_document :base_dir => base_dir, :safe => Asciidoctor::SafeMode::UNSAFE
+ expected = ::File.join base_dir, 'images', 'tiger.png'
+ actual = doc.normalize_system_path 'tiger.png', 'images'
+ assert_equal expected, actual
+ end
+
+ test 'should resolve absolute path as absolute in unsafe mode' do
+ base_dir = fixture_path 'base'
+ doc = empty_document :base_dir => base_dir, :safe => Asciidoctor::SafeMode::UNSAFE
+ actual = doc.normalize_system_path 'tiger.png', '/etc/images'
+ assert_equal '/etc/images/tiger.png', actual
+ end
end
context 'Helpers' do