From ef5b192d48cf581831d337fe1963fbb90944dc6f Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Tue, 13 Dec 2016 00:27:48 -0700 Subject: resolves #1965 make start argument to system_path optional (PR #1966) --- lib/asciidoctor/path_resolver.rb | 6 +++--- test/paths_test.rb | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/asciidoctor/path_resolver.rb b/lib/asciidoctor/path_resolver.rb index 111ff924..61350974 100644 --- a/lib/asciidoctor/path_resolver.rb +++ b/lib/asciidoctor/path_resolver.rb @@ -300,8 +300,8 @@ class PathResolver # specified in the constructor. # # target - the String target path - # start - the String start (i.e., parent) path - # jail - the String jail path to confine the resolved path + # start - the String start (i.e., parent) path (default: nil) + # jail - the String jail path to confine the resolved path (default: nil) # opts - an optional Hash of options to control processing (default: {}): # * :recover is used to control whether the processor should auto-recover # when an illegal path is encountered @@ -310,7 +310,7 @@ class PathResolver # returns a String path that joins the target path with the start path with # any parent references resolved and self references removed and enforces # that the resolved path be contained within the jail, if provided - def system_path target, start, jail = nil, opts = {} + def system_path target, start = nil, jail = nil, opts = {} if jail unless is_root? jail raise ::SecurityError, %(Jail is not an absolute path: #{jail}) diff --git a/test/paths_test.rb b/test/paths_test.rb index f7fd96c2..ab66e4cc 100644 --- a/test/paths_test.rb +++ b/test/paths_test.rb @@ -185,6 +185,7 @@ context 'Path Resolver' do pwd = File.expand_path(Dir.pwd) assert_equal "#{pwd}/images/tiger.png", @resolver.system_path('images/tiger.png', '') assert_equal "#{pwd}/images/tiger.png", @resolver.system_path('images/tiger.png', nil) + assert_equal "#{pwd}/images/tiger.png", @resolver.system_path('images/tiger.png') end test 'resolves relative hidden target relative to current directory if start is empty' do -- cgit v1.2.3