diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2016-12-13 00:27:48 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-13 00:27:48 -0700 |
| commit | ef5b192d48cf581831d337fe1963fbb90944dc6f (patch) | |
| tree | 68b254a2d88df6b04a593fb9d22a4a5098d07779 | |
| parent | 1e38a00cbd79a4f45c7e7d7b2a712759faa5b711 (diff) | |
resolves #1965 make start argument to system_path optional (PR #1966)
| -rw-r--r-- | lib/asciidoctor/path_resolver.rb | 6 | ||||
| -rw-r--r-- | 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 |
