Validate filename both before and after resolving the path (elastic/x-pack-elasticsearch#1775)
This change ensures we fail early with validation before we even attempt to resolve a path as the path resolution can fail with invalid characters on some operating systems. relates elastic/x-pack-elasticsearch#1757 Original commit: elastic/x-pack-elasticsearch@3a4243b6d6
This commit is contained in:
parent
b07a903afa
commit
3854e0aee7
|
@ -617,7 +617,8 @@ public class CertificateTool extends EnvironmentAwareCommand {
|
|||
}
|
||||
|
||||
static boolean isValidFilename(String name) {
|
||||
return ALLOWED_FILENAME_CHAR_PATTERN.matcher(resolvePath(name).toString()).matches()
|
||||
return ALLOWED_FILENAME_CHAR_PATTERN.matcher(name).matches()
|
||||
&& ALLOWED_FILENAME_CHAR_PATTERN.matcher(resolvePath(name).toString()).matches()
|
||||
&& name.startsWith(".") == false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue