else if (entry.isDirectory()) {
// check for reservedDirs
for (String reserved : RESERVED_DIRS) {
// the dir entry name has a trailing / like "dir/"
if (entryName.equals(reserved + "/")) {
throw new ValidationException("EXCEPTION_ARCHIVE_RESERVED_DIR");
}
}
}
// Validate the resource name
// Allow "_" and "." anywhere in file name
// Disallow "-" as leading character, but allow it in other positions
Pattern patternEntryName = Pattern.compile("[a-zA-Z_0-9\\.][a-zA-Z_0-9\\-\\.]*");
String entity;
String fullEntryName = entryName;
boolean noMoreEntity = false;
while (!noMoreEntity) {
if (entryName.charAt(entryName.length() - 1) == '/') {
entryName = entryName.substring(0, entryName.length() - 1); // Remove the ending '/'
}
if (entryName.lastIndexOf('/') >= 0) {
entity = entryName.substring(entryName.lastIndexOf('/') + 1);
entryName = entryName.substring(0, entryName.lastIndexOf('/'));
} else {
entity = entryName;
noMoreEntity = true;
}
if (!patternEntryName.matcher(entity).matches()) {
throw new ValidationException("EXCEPTION_INVALID_RESOURCE_NAME", fullEntryName);
}
}
}
}
if (_configXML.length == 0) {