class

Asciidoctor::PathResolver

Inherits Asciidoctor::Logging < Reference < Object

Public: Handles all operations for resolving, cleaning and joining paths. This class includes operations for handling both web paths (request URIs) and system paths.

The main emphasis of the class is on creating clean and secure paths. Clean paths are void of duplicate parent and current directory references in the path name. Secure paths are paths which are restricted from accessing directories outside of a jail path, if specified.

Since joining two paths can result in an insecure path, this class also handles the task of joining a parent (start) and child (target) path.

Constants

BACKSLASH = "\\"
DOT = "."
DOT_DOT = ".."
DOT_SLASH = "./"
DOUBLE_SLASH = "//"
SLASH = "/"
WindowsRootRx = /^(?:[a-zA-Z]:)?[\\\/]/

Constructors

new(file_separator : String | Nil = nil, working_dir : String | Nil = nil)
Source

Instance methods

absolute_path?(path : String) : Bool

Public: Check whether the specified path is an absolute path.

Source
descends_from?(path : String, base : String) : Int32 | Nil

Public: Determine whether path descends from base. Returns the offset if it descends, otherwise nil.

Source
expand_path(path : String) : String

Public: Expand the specified path by resolving parent references (..) and removing self references (.).

Source
file_separator
Source
file_separator=(file_separator : String)
Source
join_path(segments : Array(String), root : String | Nil = nil) : String

Public: Join the segments using the posix file separator.

Source
partition_path(path : String, web : Bool = false) : Tuple(Array(String), String | Nil)

Public: Partition the path into path segments and remove self references (.) and the trailing slash, if present.

Source
posixify(path : String | Nil) : String

Public: Normalize path by converting any backslashes to forward slashes.

Source
relative_path(path : String, base : String) : String

Public: Calculate the relative path to this absolute path from the specified base directory.

Source
root?(path : String) : Bool

Public: Check if the specified path is an absolute root path. In Crystal, we don't have Opal or JRuby, so root? is the same as absolute_path?.

Source
system_path(target : String | Nil, start : String | Nil = nil, jail : String | Nil = nil, opts = {} of Symbol => String | Bool) : String

Public: Securely resolve a system path.

Source
unc?(path : String) : Bool

Public: Determine if the path is a UNC (root) path.

Source
web_path(target : String | Nil, start : String | Nil = nil) : String

Public: Resolve a web path from the target and start paths.

Source
web_root?(path : String) : Bool

Public: Determine if the path is an absolute (root) web path.

Source
working_dir
Source
working_dir=(working_dir : String)
Source