Skip to content

Commit 5f3bbeb

Browse files
[Security] fix download security problem (#61162) (#61388)
* fix download security problem
1 parent 9cd0c91 commit 5f3bbeb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

python/paddle/dataset/common.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import importlib
1919
import os
2020
import pickle
21+
import re
2122
import shutil
2223
import sys
2324
import tempfile
@@ -71,6 +72,11 @@ def md5file(fname):
7172

7273

7374
def download(url, module_name, md5sum, save_name=None):
75+
module_name = re.match("^[a-zA-Z0-9_/\\-]+$", module_name).group()
76+
if isinstance(save_name, str):
77+
save_name = re.match(
78+
"^(?:(?!\\.\\.)[a-zA-Z0-9_/\\.-])+$", save_name
79+
).group()
7480
dirname = os.path.join(DATA_HOME, module_name)
7581
if not os.path.exists(dirname):
7682
os.makedirs(dirname)

0 commit comments

Comments
 (0)