Function
RBuri_is_descendant
Declaration [src]
gboolean
rb_uri_is_descendant (
const char* uri,
const char* ancestor
)
Description [src]
Checks if uri
refers to a path beneath ancestor
, such that removing some number
of path segments of uri
would result in ancestor
.
It doesn’t do any filesystem operations, it just looks at the URIs as strings.
The URI strings should be built by looking at a filesystem rather than user input,
and must not have path segments that are empty (multiple slashes) or ‘.’ or ‘..’.
Given this input, checking if one URI is a descendant of another is pretty simple. A descendant URI must have the ancestor as a prefix, and if the ancestor ends with a slash, there must be at least one character after that, otherwise the following character must be a slash with at least one character after it.