mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-11-16 01:21:16 +01:00
Update app/core/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java
safe handling of bounds Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
a506fe43da
commit
a5efaf3009
@ -645,10 +645,16 @@ public class WatermarkController {
|
|||||||
if (request.getBounds() != null && !request.getBounds().isEmpty()) {
|
if (request.getBounds() != null && !request.getBounds().isEmpty()) {
|
||||||
String[] boundsParts = request.getBounds().split(",");
|
String[] boundsParts = request.getBounds().split(",");
|
||||||
if (boundsParts.length == 4) {
|
if (boundsParts.length == 4) {
|
||||||
|
try {
|
||||||
boundsX = Float.parseFloat(boundsParts[0].trim());
|
boundsX = Float.parseFloat(boundsParts[0].trim());
|
||||||
boundsY = Float.parseFloat(boundsParts[1].trim());
|
boundsY = Float.parseFloat(boundsParts[1].trim());
|
||||||
boundsWidth = Float.parseFloat(boundsParts[2].trim());
|
boundsWidth = Float.parseFloat(boundsParts[2].trim());
|
||||||
boundsHeight = Float.parseFloat(boundsParts[3].trim());
|
boundsHeight = Float.parseFloat(boundsParts[3].trim());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
log.warn("Invalid bounds format: {}", request.getBounds(), e);
|
||||||
|
return ResponseEntity.badRequest()
|
||||||
|
.body(WebResponseUtils.error("Invalid bounds format. Expected four comma-separated numbers."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user