Browse Source

Don't allow the custom validation methods to evade superclass validation.

qdn-file-list
CalDescent 2 years ago
parent
commit
c3f19ea0c1
  1. 21
      src/main/java/org/qortal/arbitrary/misc/Service.java

21
src/main/java/org/qortal/arbitrary/misc/Service.java

@ -20,7 +20,12 @@ public enum Service {
ARBITRARY_DATA(100, false, null, null),
QCHAT_ATTACHMENT(120, true, 1024*1024L, null) {
@Override
public ValidationResult validate(Path path) {
public ValidationResult validate(Path path) throws IOException {
ValidationResult superclassResult = super.validate(path);
if (superclassResult != ValidationResult.OK) {
return superclassResult;
}
// Custom validation function to require a single file, with a whitelisted extension
int fileCount = 0;
File[] files = path.toFile().listFiles();
@ -49,7 +54,12 @@ public enum Service {
},
WEBSITE(200, true, null, null) {
@Override
public ValidationResult validate(Path path) {
public ValidationResult validate(Path path) throws IOException {
ValidationResult superclassResult = super.validate(path);
if (superclassResult != ValidationResult.OK) {
return superclassResult;
}
// Custom validation function to require an index HTML file in the root directory
List<String> fileNames = ArbitraryDataRenderer.indexFiles();
String[] files = path.toFile().list();
@ -80,7 +90,12 @@ public enum Service {
METADATA(1100, false, null, null),
GIF_REPOSITORY(1200, true, 25*1024*1024L, null) {
@Override
public ValidationResult validate(Path path) {
public ValidationResult validate(Path path) throws IOException {
ValidationResult superclassResult = super.validate(path);
if (superclassResult != ValidationResult.OK) {
return superclassResult;
}
// Custom validation function to require .gif files only, and at least 1
int gifCount = 0;
File[] files = path.toFile().listFiles();

Loading…
Cancel
Save