Skip to content

Commit

Permalink
Added : to the cleaning of filenames (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-tco authored Oct 10, 2023
1 parent b8395e6 commit 0f6d1e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class SubmissionController {
private final Logger logger = LoggerFactory.getLogger(SubmissionController.class);
private final Clock clock;

private static final String SPECIAL_CHARACTER_REGEX = "[<>\"\\\\/|?*]";
private static final String SPECIAL_CHARACTER_REGEX = "[<>\"\\\\/|?*:]";

@GetMapping
public ResponseEntity<List<GetSubmissionDto>> getSubmissions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class SubmissionControllerTest {
final String SECTION_ID_2 = "CUSTOM_SECTION_1";
final String SECTION_TITLE_1 = "Eligibility";
final String SECTION_TITLE_2 = "Project Status";
final String SPECIAL_CHARACTER_REGEX = "[<>\"\\\\/|?*:]";
final GrantScheme scheme = GrantScheme.builder()
.id(1)
.version(1)
Expand Down Expand Up @@ -790,7 +791,7 @@ void postAttachment_SavesTheDocumentCleansFilenameAndCreatesADatabaseEntry() {

final MultipartFile file = new MockMultipartFile(
"file",
"<>/?|hello.txt",
"<>/?|/:hello.txt",
MediaType.TEXT_PLAIN_VALUE,
"Hello, World!".getBytes()
);
Expand All @@ -810,7 +811,7 @@ void postAttachment_SavesTheDocumentCleansFilenameAndCreatesADatabaseEntry() {

final ResponseEntity<GetNavigationParamsDto> methodResponse = controllerUnderTest.postAttachment(SUBMISSION_ID, SECTION_ID_2, questionId, file);

verify(attachmentService).attachmentFile(application.getId() + "/" + SUBMISSION_ID + "/" + questionId + "/" + file.getOriginalFilename().replaceAll("[<>\"\\\\/|?*\\\\]", "_"), file);
verify(attachmentService).attachmentFile(application.getId() + "/" + SUBMISSION_ID + "/" + questionId + "/" + file.getOriginalFilename().replaceAll(SPECIAL_CHARACTER_REGEX, "_"), file);
verify(grantAttachmentService).createAttachment(attachmentCaptor.capture());
verify(submissionService).saveSubmission(submission);

Expand Down

0 comments on commit 0f6d1e7

Please sign in to comment.