Method: Asciidoctor::AbstractNode#normalize_system_path
- Defined in:
- lib/asciidoctor/abstract_node.rb
#normalize_system_path(target, start = nil, jail = nil, opts = {}) ⇒ String
Resolve and normalize a secure path from the target and start paths using the PathResolver.
See PathResolver#system_path for details.
The most important functionality in this method is to prevent resolving a path outside of the jail (which defaults to the directory of the source file, stored in the base_dir instance variable on Document) if the document safe level is set to SafeMode::SAFE or greater (a condition which is true by default).
458 459 460 461 462 463 464 465 466 467 468 469 470 |
# File 'lib/asciidoctor/abstract_node.rb', line 458 def normalize_system_path target, start = nil, jail = nil, opts = {} if (doc = @document).safe < SafeMode::SAFE if start start = ::File.join doc.base_dir, start unless doc.path_resolver.root? start else start = doc.base_dir end else start ||= doc.base_dir jail ||= doc.base_dir end doc.path_resolver.system_path target, start, jail, opts end |