414114b7a5f565e00fc143898a3620ddccdfc504,mmdnn/conversion/common/utils.py,,download_file,#Any#Any#Any#Any#Any#Any#,194

Before Change



    if auto_unzip:
        if ret.endswith(".tar.gz") or ret.endswith(".tgz"):
            try:
                import tarfile
                tar = tarfile.open(ret)
                tar.extractall(directory)
                tar.close()
            except:
                print("Unzip file [{}] failed.".format(ret))

        elif ret.endswith(".zip"):
            try:
                import zipfile
                zip_ref = zipfile.ZipFile(ret, "r")

After Change


                import tarfile
                tar = tarfile.open(ret)
                for name in tar.getnames():
                    if not (os.path.realpath(os.path.join(directory, name))+ os.sep).startswith(os.path.realpath(directory) + os.sep):
                        raise ValueError("The decompression path does not match the current path. For more info: https://docs.python.org/3/library/tarfile.html//tarfile.TarFile.extractall")
                tar.extractall(directory)
                tar.close()
            except ValueError:
                raise
            except:
                print("Unzip file [{}] failed.".format(ret))

        elif ret.endswith(".zip"):
            try:
                import zipfile
                zip_ref = zipfile.ZipFile(ret, "r")
                for name in zip_ref.namelist():
                    if not (os.path.realpath(os.path.join(directory, name))+ os.sep).startswith(os.path.realpath(directory) + os.sep):
                        raise ValueError("The decompression path does not match the current path. For more info: https://docs.python.org/3/library/zipfile.html?highlight=zipfile//zipfile.ZipFile.extractall")
                zip_ref.extractall(directory)
                zip_ref.close()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: Microsoft/MMdnn
Commit Name: 414114b7a5f565e00fc143898a3620ddccdfc504
Time: 2019-12-03
Author: 42927787+rainLiuplus@users.noreply.github.com
File Name: mmdnn/conversion/common/utils.py
Class Name:
Method Name: download_file


Project Name: Microsoft/MMdnn
Commit Name: 414114b7a5f565e00fc143898a3620ddccdfc504
Time: 2019-12-03
Author: 42927787+rainLiuplus@users.noreply.github.com
File Name: mmdnn/conversion/common/utils.py
Class Name:
Method Name: download_file


Project Name: mne-tools/mne-python
Commit Name: 2fb7d896cf9c78bee5ac092b211bae6bcd1efa9e
Time: 2019-04-25
Author: mainakjas@gmail.com
File Name: mne/realtime/tests/test_fieldtrip_client.py
Class Name:
Method Name: test_fieldtrip_rtepochs


Project Name: mne-tools/mne-python
Commit Name: 2fb7d896cf9c78bee5ac092b211bae6bcd1efa9e
Time: 2019-04-25
Author: mainakjas@gmail.com
File Name: mne/realtime/tests/test_fieldtrip_client.py
Class Name:
Method Name: test_fieldtrip_client