Commit 458219f7 authored by Enriko Käsper's avatar Enriko Käsper
Browse files

Merge branch 'hotfix/TEIS-1417' into 'master'

Release: merge 'hotfix-teis-1417' into 'master' created by Jürgen Hannus

See merge request teis/common-api-gateway!113
parents 6b04da62 53fee2d3
......@@ -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