Commit 53fee2d3 authored by Jyrgen Hannus's avatar Jyrgen Hannus
Browse files

TEIS-1417: when uploading file and file extension from name is being parsed...

TEIS-1417: when uploading file and file extension from name is being parsed and validated then the allowed extension list and file name extension are now case insensitive
parent 6b04da62
......@@ -30,6 +30,7 @@ import java.util.concurrent.CompletableFuture;
import static ee.sm.ti.teis.errors.CommonErrorCode.BAD_REQUEST;
import static ee.sm.ti.teis.errors.CommonErrorCode.UNSUPPORTED_MEDIA_TYPE;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.io.FilenameUtils.getExtension;
@Service
......@@ -152,9 +153,13 @@ public class FileContentService {
}
}
private void validateFileExtensionAllowed(String fileName) {
void validateFileExtensionAllowed(String fileName) {
List<String> caseInsensitiveAllowedExtensions = allowedExtensions.stream()
.map(String::toLowerCase)
.collect(toList());
String extension = getExtension(fileName);
if (!allowedExtensions.contains(extension)) {
if (!caseInsensitiveAllowedExtensions.contains(extension.toLowerCase())) {
throw new TeisRestException(ErrorDTO.builder()
.code(UNSUPPORTED_MEDIA_TYPE.getCode())
.httpResponse(HttpStatus.UNSUPPORTED_MEDIA_TYPE)
......
theGroup=ee.sm.ti.teis
//commonApiGatewayVersion=forSearch ^commonApiGatewayVersion=.*?-SNAPSHOT
theVersion=1.6.0
theVersion=1.6.1
commonsVersion=1.6.0
pluginVersion=1.0.1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment