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,11 +142,26 @@ public class Worker {
|
||||
}
|
||||
|
||||
if (cache_dir != null) {
|
||||
Pattern cache_dirValidator = Pattern.compile("^(\\/|\\\\|[a-z]:)[a-z0-9\\/\\\\-_.]+$",Pattern.CASE_INSENSITIVE);
|
||||
Matcher cache_dirCandidate = cache_dirValidator.matcher(cache_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);
|
||||
}
|
||||
}
|
||||
|
||||
// We set a hard limit of 3 concurrent uploads. As the server doesn't allocate more than 3 concurrent jobs to
|
||||
|
||||
Reference in New Issue
Block a user