Skip to content

Restrict file extension change during attachment rename#474

Merged
vibhutikumar07 merged 9 commits into
developfrom
fileType
May 6, 2026
Merged

Restrict file extension change during attachment rename#474
vibhutikumar07 merged 9 commits into
developfrom
fileType

Conversation

@deepikaSingh2711

@deepikaSingh2711 deepikaSingh2711 commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator

Describe your changes

When renaming an attachment, users could change the file extension (e.g., sample.pdf → sample.dmg), corrupting the document type and making downloaded files unopenable.

Changes:

-> Added getFileExtension() and hasFileExtensionChanged() utilities in SDMUtils
-> Added extension validation in updateFilenameProperty() — if extension changes, the rename is skipped, the filename is reverted to the original, and a warning is shown to the user
-> Applied to both Update and Create handler flows

Behavior:

sample.pdf → report.pdf Allowed
sample.pdf → sample.dmg Warning shown, filename will be reverted

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist before requesting a review

  • I follow Java Development Guidelines for SAP
  • I have tested the functionality on my cloud environment.
  • I have provided sufficient automated/ unit tests for the code.
  • I have increased or maintained the test coverage.
  • I have ran integration tests on my cloud environment.
  • I have validated blackduck portal for any vulnerability after my commit.

Upload Screenshots/lists of the scenarios tested

  • I have Uploaded Screenshots or added lists of the scenarios tested in description
Screenshot 2026-04-30 at 2 03 11 PM

SINGLE TENANT INTEGRATION TEST

https://github.com/cap-java/sdm/actions/runs/25163159892
Screenshot 2026-05-04 at 9 18 07 AM

MULTI TENANT INTEGRATION TEST

https://github.com/cap-java/sdm/actions/runs/25163208769

Screenshot 2026-05-04 at 9 19 12 AM

@yashmeet29

Copy link
Copy Markdown
Contributor

Hi @deepikaSingh2711, please attach the Screenshot of Integration tests

@deepikaSingh2711

Copy link
Copy Markdown
Collaborator Author

Hi @deepikaSingh2711, please attach the Screenshot of Integration tests

I Have added it

rashmiangadi05
rashmiangadi05 previously approved these changes May 5, 2026
Comment on lines +150 to +151
public static final String FILE_EXTENSION_CHANGE_NOT_ALLOWED =
"Changing the file extension is not allowed. The file \"%s\" must retain its original extension \"%s\".";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deepikaSingh2711, please add the corresponding key for this error message for translation

@deepikaSingh2711 deepikaSingh2711 May 5, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@vibhutikumar07 vibhutikumar07 merged commit 5982a24 into develop May 6, 2026
8 checks passed
@vibhutikumar07 vibhutikumar07 deleted the fileType branch May 6, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants