File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -222,12 +222,12 @@ def anyfile(infile, mode="r"):
222222 except KeyError :
223223 # provided rawfile does not appear in the tarball
224224 tar_file .close ()
225- raise Exception ("target member does not contain the provided tar file." )
225+ raise FileNotFoundError ("target member does not contain the provided tar file." )
226226
227227 # extracted member is not a regular file or link
228228 if extracted is None :
229229 tar_file .close ()
230- raise Exception ("invalid target file: must be a regular file or a link" )
230+ raise ValueError ("invalid target file: must be a regular file or a link" )
231231
232232 return io .TextIOWrapper (extracted )
233233
@@ -807,7 +807,7 @@ def sanitize_tarfile(tar_object, directory):
807807 abs_target = os .path .abspath (target )
808808 prefix = os .path .commonprefix ([abs_directory , abs_target ])
809809 if not prefix == abs_directory :
810- raise Exception ("Attempted Path Traversal in Tar File" )
810+ raise ValueError ("Attempted Path Traversal in Tar File" )
811811
812812
813813def sizeof_fmt (num , suffix = "B" ):
You can’t perform that action at this time.
0 commit comments