diff options
| author | cjybyjk <cjybyjk@zjnu.edu.cn> | 2021-06-18 15:24:46 +0800 |
|---|---|---|
| committer | cjybyjk <cjybyjk@zjnu.edu.cn> | 2021-06-18 16:51:04 +0800 |
| commit | 9aebfe62786166abc50628ad282957e3024363a5 (patch) | |
| tree | c01aa25554bb74f3504c5ca020a4aeae2df56b04 | |
| parent | 1136b83678fd5ced21a305c4fd774f19455cf877 (diff) | |
fix: regex for IP & MAC address
Signed-off-by: cjybyjk <cjybyjk@zjnu.edu.cn>
Change-Id: I63ca071f3a5faef20831d379dc7776c86e20869e
| -rw-r--r-- | app/src/main/java/org/exthmui/softap/SoftApManageService.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/src/main/java/org/exthmui/softap/SoftApManageService.java b/app/src/main/java/org/exthmui/softap/SoftApManageService.java index 1bc9b3d..800050c 100644 --- a/app/src/main/java/org/exthmui/softap/SoftApManageService.java +++ b/app/src/main/java/org/exthmui/softap/SoftApManageService.java @@ -274,11 +274,11 @@ public class SoftApManageService extends Service implements WifiManager.SoftApCa } private boolean isValidMACAddress(String mac) { - return mac != null && mac.matches("..:..:..:..:..:.."); + return mac != null && mac.matches("([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}"); } private boolean isIPV4Address(String ip) { - return ip != null && ip.matches("[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}"); + return ip != null && ip.matches("((25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))\\.){3}(25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))"); } private boolean isReachable(String ip) { |
