mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
fix(stamp): validate image filename only for image stamp type (#4099)
# Description of Changes - **What was changed**: Moved the filename validation logic for `stampImage` inside a condition that checks whether the stamp type is `"image"`. - **Why the change was made**: Previously, the validation was applied regardless of stamp type, leading to unnecessary errors for non-image-based stamps where no `stampImage` is provided. Closes #4097 --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. --------- Co-authored-by: Copilot <[email protected]>
This commit is contained in:
+6
-1
@@ -70,10 +70,15 @@ public class StampController {
|
|||||||
String stampType = request.getStampType();
|
String stampType = request.getStampType();
|
||||||
String stampText = request.getStampText();
|
String stampText = request.getStampText();
|
||||||
MultipartFile stampImage = request.getStampImage();
|
MultipartFile stampImage = request.getStampImage();
|
||||||
|
if ("image".equalsIgnoreCase(stampType)) {
|
||||||
|
if (stampImage == null) {
|
||||||
|
throw new IllegalArgumentException("Stamp image file must be provided when stamp type is 'image'");
|
||||||
|
}
|
||||||
String stampImageName = stampImage.getOriginalFilename();
|
String stampImageName = stampImage.getOriginalFilename();
|
||||||
if (stampImageName.contains("..") || stampImageName.startsWith("/")) {
|
if (stampImageName == null || stampImageName.contains("..") || stampImageName.startsWith("/")) {
|
||||||
throw new IllegalArgumentException("Invalid stamp image file path");
|
throw new IllegalArgumentException("Invalid stamp image file path");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
String alphabet = request.getAlphabet();
|
String alphabet = request.getAlphabet();
|
||||||
float fontSize = request.getFontSize();
|
float fontSize = request.getFontSize();
|
||||||
float rotation = request.getRotation();
|
float rotation = request.getRotation();
|
||||||
|
|||||||
Reference in New Issue
Block a user