Skip to content

Commit

Permalink
[Security] fix download security problem (#61162) (#61388)
Browse files Browse the repository at this point in the history
* fix download security problem
  • Loading branch information
wanghuancoder authored Feb 1, 2024
1 parent 9cd0c91 commit 5f3bbeb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/paddle/dataset/common.py
Original file line number Diff line number Diff line change
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 5f3bbeb

Please sign in to comment.