Skip to content

Commit

Permalink
[Security] fix download security problem (#61162)
Browse files Browse the repository at this point in the history
* fix download security problem
  • Loading branch information
wanghuancoder committed Jan 31, 2024
1 parent 62a1261 commit 5c50d1a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/paddle/dataset/common.py
Expand Up @@ -18,6 +18,7 @@
import importlib
import os
import pickle
import re
import shutil
import sys
import tempfile
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5c50d1a

Please sign in to comment.