Skip to content

Commit

Permalink
PR review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Oliveira committed Jan 29, 2024
1 parent fa751c8 commit 6427cc9
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,14 @@ public Object upload(MultipartFile file, RequestContext context) throws Response
String fileName = file.getOriginalFilename();
int idx = fileName.lastIndexOf(".");
String fileExtension = idx > 0 && idx < fileName.length() - 1 ? fileName.substring(idx + 1) : "";
if (!Arrays.stream(ctx.getAllowedFileExtensions()).filter(e -> e.equalsIgnoreCase(fileExtension)).findAny()
.isPresent()) {
if (!ArrayUtils.isEmpty(ctx.getAllowedFileExtensions()) && !Arrays.stream(ctx.getAllowedFileExtensions())
.filter(e -> e.equalsIgnoreCase(fileExtension)).findAny().isPresent()) {
throw new IllegalRequestException("The extension is not valid");
}

// Verify file name
if (Arrays.stream(ctx.getAllowedFileExtensions()).filter(e -> e.equalsIgnoreCase(fileName)).findAny().isPresent()) {
if (!ArrayUtils.isEmpty(ctx.getDeniedFileNames())
&& Arrays.stream(ctx.getDeniedFileNames()).filter(e -> e.equalsIgnoreCase(fileName)).findAny().isPresent()) {
throw new IllegalRequestException("The file name is not valid");
}

Expand Down

0 comments on commit 6427cc9

Please sign in to comment.