Skip to content

Commit 76c7e99

Browse files
authored
🐛 #3700 修复空指针问题
1 parent 092e992 commit 76c7e99

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ public static String wxMpOutXmlMessageToEncryptedXml(WxMpXmlOutMessage message,
299299

300300
public static WxOpenXmlMessage fromXml(String xml) {
301301
//修改微信变态的消息内容格式,方便解析
302-
xml = xml.replace("</PicList><PicList>", "");
302+
if (xml != null) {
303+
xml = xml.replace("</PicList><PicList>", "");
304+
}
303305
return XStreamTransformer.fromXml(WxOpenXmlMessage.class, xml);
304306
}
305307

@@ -321,6 +323,11 @@ public static WxOpenXmlMessage fromEncryptedXml(String encryptedXml, WxOpenConfi
321323
WxOpenCryptUtil cryptUtil = new WxOpenCryptUtil(wxOpenConfigStorage);
322324
String plainText = cryptUtil.decryptXml(msgSignature, timestamp, nonce, encryptedXml);
323325
log.debug("解密后的原始xml消息内容:{}", plainText);
326+
327+
if (plainText == null || plainText.trim().isEmpty()) {
328+
throw new WxRuntimeException("解密后的xml消息内容为空,请检查加密参数是否正确");
329+
}
330+
324331
WxOpenXmlMessage wxOpenXmlMessage = fromXml(plainText);
325332
wxOpenXmlMessage.setContext(plainText);
326333
return wxOpenXmlMessage;

0 commit comments

Comments
 (0)