Add a method to prevent special characters in the cache path
This commit is contained in:
committed by
Sheepit Renderfarm
parent
46ad1882a7
commit
fa82be607c
@@ -142,10 +142,25 @@ public class Worker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cache_dir != null) {
|
if (cache_dir != null) {
|
||||||
File a_dir = new File(cache_dir);
|
Pattern cache_dirValidator = Pattern.compile("^(\\/|\\\\|[a-z]:)[a-z0-9\\/\\\\-_.]+$",Pattern.CASE_INSENSITIVE);
|
||||||
a_dir.mkdirs();
|
Matcher cache_dirCandidate = cache_dirValidator.matcher(cache_dir);
|
||||||
if (a_dir.isDirectory() && a_dir.canWrite()) {
|
|
||||||
config.setCacheDir(a_dir);
|
if (cache_dirCandidate.find()) {
|
||||||
|
|
||||||
|
File a_dir = new File(cache_dir);
|
||||||
|
a_dir.mkdirs();
|
||||||
|
if (a_dir.isDirectory() && a_dir.canWrite()) {
|
||||||
|
config.setCacheDir(a_dir);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.err.println("ERROR: The entered cache path is either not a directory or is not writable!");
|
||||||
|
System.exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.err.println("ERROR: The entered cache path (-cache-dir parameter) contains invalid characters. Allowed characters are a-z, A-Z, 0-9, /, \\, ., - and _");
|
||||||
|
System.exit(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user