From 0189e612fb6a1aaa0c4a4d7ba5362c507debdcaa Mon Sep 17 00:00:00 2001 From: f0ng Date: Mon, 21 Mar 2022 18:16:44 +0800 Subject: [PATCH] Update TableModel.java --- src/main/java/ui/model/TableModel.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/ui/model/TableModel.java b/src/main/java/ui/model/TableModel.java index 5e34b30..90afbaf 100644 --- a/src/main/java/ui/model/TableModel.java +++ b/src/main/java/ui/model/TableModel.java @@ -59,11 +59,14 @@ public Object getValueAt(int row, int column) { case 0: String strr = new String(captcha.getImage()); if ( (strr.contains("data:image") && !strr.startsWith("data:image")) || (strr.contains("data%3Aimage") && !strr.startsWith("data%3Aimage")) ){ - String pattern = "(data:image.*?)[\"|&]|(data%2Aimage.*?)[\"|&]"; + String pattern = "(data:image.*?)[\"|&]|(data%2Aimage.*?)[\"|&]|([B|b]ase64\".*)[\"|&]"; Pattern r = Pattern.compile(pattern); Matcher m = r.matcher(strr); if (m.find( )) { - strr = m.group(0).replace("\"","").replace("&","") ; + strr = m.group(0).replace("\"","").replace("&","").replace("Base64:","").replace("base64:","") ; + } + if (!strr.contains("data:image")){ + strr = "data:image/jpeg;base64," + strr; } byte[] byteImage = DatatypeConverter.parseBase64Binary(strr.substring(strr.indexOf(",") + 1)); ImageIcon icon = byte2img(byteImage);