KEYCLOAK-699 Set maximum size of qr-code
This commit is contained in:
parent
61b71082f7
commit
ed895ce02d
1 changed files with 10 additions and 2 deletions
|
@ -43,14 +43,22 @@ public class QRCodeResource {
|
|||
|
||||
if (size != null) {
|
||||
String[] s = size.split("x");
|
||||
try {
|
||||
width = Integer.parseInt(s[0]);
|
||||
height = Integer.parseInt(s[1]);
|
||||
} catch (Throwable t) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
}
|
||||
|
||||
if (contents == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
|
||||
if (width > 1000 || height > 1000 || contents.length() > 1000) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
|
||||
QRCodeWriter writer = new QRCodeWriter();
|
||||
final BitMatrix bitMatrix = writer.encode(contents, BarcodeFormat.QR_CODE, width, height);
|
||||
|
||||
|
|
Loading…
Reference in a new issue