2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-22 09:58:08 +00:00

Enforce format of device IDs

This commit is contained in:
Albert Vaca Cintora 2024-12-31 17:49:16 +01:00
parent 56c96b686d
commit 13b09ffae8

View File

@ -105,8 +105,13 @@ class DeviceInfo(
fun isValidIdentityPacket(identityPacket: NetworkPacket): Boolean = with(identityPacket) {
type == NetworkPacket.PACKET_TYPE_IDENTITY &&
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)
}
}