MCPcopy Create free account
hub / github.com/THUDM/GLM / is_within_directory

Method is_within_directory

model/modeling_bert.py:773–780  ·  view source on GitHub ↗
(directory, target)

Source from the content-addressed store, hash-verified

771 resolved_archive_file, tempdir))
772 with tarfile.open(resolved_archive_file, 'r:gz') as archive:
773 def is_within_directory(directory, target):
774
775 abs_directory = os.path.abspath(directory)
776 abs_target = os.path.abspath(target)
777
778 prefix = os.path.commonprefix([abs_directory, abs_target])
779
780 return prefix == abs_directory
781
782 def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
783

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected