mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-28 12:47:43 +00:00
Enforce format of device IDs
This commit is contained in:
parent
56c96b686d
commit
13b09ffae8
@ -105,8 +105,13 @@ class DeviceInfo(
|
|||||||
fun isValidIdentityPacket(identityPacket: NetworkPacket): Boolean = with(identityPacket) {
|
fun isValidIdentityPacket(identityPacket: NetworkPacket): Boolean = with(identityPacket) {
|
||||||
type == NetworkPacket.PACKET_TYPE_IDENTITY &&
|
type == NetworkPacket.PACKET_TYPE_IDENTITY &&
|
||||||
DeviceHelper.filterName(getString("deviceName", "")).isNotBlank() &&
|
DeviceHelper.filterName(getString("deviceName", "")).isNotBlank() &&
|
||||||
getString("deviceId", "").isNotBlank()
|
isValidDeviceId(getString("deviceId", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val DEVICE_ID_REGEX = "^_?[a-fA-F0-9]{8}_?[a-fA-F0-9]{4}_?[a-fA-F0-9]{4}_?[a-fA-F0-9]{4}_?[a-fA-F0-9]{12}_?\$".toRegex()
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun isValidDeviceId(deviceId: String): Boolean = deviceId.matches(DEVICE_ID_REGEX)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user