diff --git a/src/org/kde/kdeconnect/DeviceInfo.kt b/src/org/kde/kdeconnect/DeviceInfo.kt index 65539d80..b35a9833 100644 --- a/src/org/kde/kdeconnect/DeviceInfo.kt +++ b/src/org/kde/kdeconnect/DeviceInfo.kt @@ -108,7 +108,7 @@ class DeviceInfo( 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() + private val DEVICE_ID_REGEX = "^[a-zA-Z0-9_]{32,38}\$".toRegex() @JvmStatic fun isValidDeviceId(deviceId: String): Boolean = deviceId.matches(DEVICE_ID_REGEX) diff --git a/tests/org/kde/kdeconnect/DeviceTest.kt b/tests/org/kde/kdeconnect/DeviceTest.kt index d43b7629..c768b296 100644 --- a/tests/org/kde/kdeconnect/DeviceTest.kt +++ b/tests/org/kde/kdeconnect/DeviceTest.kt @@ -144,15 +144,12 @@ class DeviceTest { @Test fun testIsValidDeviceId() { + Assert.assertTrue(isValidDeviceId("27456E3C_fE5C_4208_96A7_c0CAEEC5E5A0")) Assert.assertTrue(isValidDeviceId("27456e3c_fe5c_4208_96a7_c0caeec5e5a0")) - Assert.assertFalse(isValidDeviceId("7456e3c_fe5c_4208_96a7_c0caeec5e5a0")) - Assert.assertFalse(isValidDeviceId("127456e3cfe5c420896a7c0caeec5e5a0")) Assert.assertTrue(isValidDeviceId("27456e3cfe5c420896a7c0caeec5e5a0")) Assert.assertFalse(isValidDeviceId("7456e3cfe5c420896a7c0caeec5e5a0")) Assert.assertTrue(isValidDeviceId("_27456e3c_fe5c_4208_96a7_c0caeec5e5a0_")) - Assert.assertFalse(isValidDeviceId("_7456e3c_fe5c_4208_96a7_c0caeec5e5a0_")) - Assert.assertFalse(isValidDeviceId("_7456e3c_fe5c_4208_96a7_c0caeec_e5a0_")) - Assert.assertFalse(isValidDeviceId("_7456z3c_fe5c_4208_96a7_c0caeec_e5a0_")) + Assert.assertTrue(isValidDeviceId("z7456e3c_fe5c_4208_96a7_c0caeec5e5a0")) Assert.assertFalse(isValidDeviceId("")) Assert.assertFalse(isValidDeviceId("______")) Assert.assertFalse(isValidDeviceId("____"))