mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-20 00:06:53 +08:00
路径遍历
This commit is contained in:
@@ -119,6 +119,10 @@ public class ContentPackageGenerator {
|
||||
private String scormPkgDir;
|
||||
|
||||
public ContentPackage generateContentPackageFromFile(String scormPkgDir) {
|
||||
if (scormPkgDir.contains("..")) {
|
||||
throw new SecurityException("输入路径包含不安全的字符");
|
||||
}
|
||||
|
||||
if (scormPkgDir == null) {
|
||||
log.error("scorm package directory is null");
|
||||
return contentPackage;
|
||||
|
||||
@@ -44,6 +44,10 @@ public class FileUtils {
|
||||
}
|
||||
|
||||
public static File createFile(String dstPath, String fileName) throws IOException {
|
||||
if (dstPath.contains("..") || fileName.contains("..")) {
|
||||
throw new SecurityException("输入路径包含不安全的字符");
|
||||
}
|
||||
|
||||
String[] dirs = fileName.split("/");
|
||||
File file = new File(dstPath);
|
||||
|
||||
|
||||
@@ -119,6 +119,11 @@ public class SCORMPackageManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (packagePath.contains("..")) {
|
||||
// throw new SecurityException("输入路径包含不安全的字符");
|
||||
return null;
|
||||
}
|
||||
|
||||
// step 1: uncompress
|
||||
File f=new File(packagePath);
|
||||
if(!f.exists()) {
|
||||
|
||||
@@ -60,6 +60,10 @@ public class ZipUtils {
|
||||
}
|
||||
|
||||
public static boolean decompressZip(String zipFilePath, String saveFileDir) {
|
||||
if (saveFileDir.contains("..")) {
|
||||
throw new SecurityException("输入路径包含不安全的字符");
|
||||
}
|
||||
|
||||
if (!isEndWithZip(zipFilePath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user