diff --git a/python/paddle/dataset/common.py b/python/paddle/dataset/common.py index 4695b633ffa0fd..35155a2de2d226 100644 --- a/python/paddle/dataset/common.py +++ b/python/paddle/dataset/common.py @@ -18,6 +18,7 @@ import importlib import os import pickle +import re import shutil import sys import tempfile @@ -71,6 +72,11 @@ def md5file(fname): def download(url, module_name, md5sum, save_name=None): + module_name = re.match("^[a-zA-Z0-9_/\\-]+$", module_name).group() + if isinstance(save_name, str): + save_name = re.match( + "^(?:(?!\\.\\.)[a-zA-Z0-9_/\\.-])+$", save_name + ).group() dirname = os.path.join(DATA_HOME, module_name) if not os.path.exists(dirname): os.makedirs(dirname)