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:
Anton Arhipov 2025-10-29 13:34:25 +02:00 committed by GitHub
parent a506fe43da
commit a5efaf3009
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -645,10 +645,16 @@ public class WatermarkController {
if (request.getBounds() != null && !request.getBounds().isEmpty()) {
String[] boundsParts = request.getBounds().split(",");
if (boundsParts.length == 4) {
boundsX = Float.parseFloat(boundsParts[0].trim());
boundsY = Float.parseFloat(boundsParts[1].trim());
boundsWidth = Float.parseFloat(boundsParts[2].trim());
boundsHeight = Float.parseFloat(boundsParts[3].trim());
try {
boundsX = Float.parseFloat(boundsParts[0].trim());
boundsY = Float.parseFloat(boundsParts[1].trim());
boundsWidth = Float.parseFloat(boundsParts[2].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."));
}
}
}