KEYCLOAK-699 Set maximum size of qr-code
This commit is contained in:
1 parent
7e03c74bc3
commit
a697f4bd41
1 file changed
+10
-2
@@ -43,14 +43,22 @@ public class QRCodeResource {
|
||||
|
||||
if (size != null) {
|
||||
String[] s = size.split("x");
|
||||
width = Integer.parseInt(s[0]);
|
||||
height = Integer.parseInt(s[1]);
|
||||
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);
|
||||
|
||||
|
||||
Reference in new issue
Block a user