(root, subpath)
return path
Join root to subpath ensuring that the result is actually inside root
Join root to subpath ensuring that the result is actually inside root
Join root to subpath ensuring that the result is actually inside root
def safejoin(root, subpath):
    """Join root to subpath ensuring that the result is actually inside root
    """
    check_safe_key(subpath)
    root = realpath(root)
    path = realpath(join(root, subpath))
    if commonprefix([root + sep, path]) != root + sep:
        raise BadName("invalid relative path: %r" % subpath)
    return path
def safejoin ( root , subpath ) : check_safe_key ( subpath ) root = realpath ( root ) path = realpath ( join ( root , subpath ) ) if commonprefix ( [ root + sep , path ] ) != root + sep : raise BadName ( "invalid relative path: %r" % subpath ) return path