!1007 修复:IdcardUtil.getGenderByIdCard存在潜在的异常:IndexOutOfBoundsException

Merge pull request !1007 from dazer007/v5-dev-getGenderByIdCard-bug-fix
This commit is contained in:
Looly
2023-06-02 09:11:15 +00:00
committed by Gitee

View File

@@ -552,7 +552,7 @@ public class IdcardUtil {
public static int getGenderByIdCard(String idcard) {
Assert.notBlank(idcard);
final int len = idcard.length();
if (len < CHINA_ID_MIN_LENGTH) {
if (!(len == CHINA_ID_MIN_LENGTH || len == CHINA_ID_MAX_LENGTH)) {
throw new IllegalArgumentException("ID Card length must be 15 or 18");
}