Commit 077c238f authored by Christophe Deschamps's avatar Christophe Deschamps
Browse files

Prevent VCard validation from crashing when device type is missing

parent e8b3c90f
Pipeline #48011 passed with stage
in 7 minutes and 5 seconds
...@@ -30,28 +30,28 @@ import org.linphone.core.tools.Log ...@@ -30,28 +30,28 @@ import org.linphone.core.tools.Log
fun Vcard.isValid(): Boolean { fun Vcard.isValid(): Boolean {
val card = this val card = this
val validType = card.getExtendedPropertiesValuesByName(Device.vcard_device_type_header) val validType = if (card.getExtendedPropertiesValuesByName(Device.vcard_device_type_header).size == 1) (card.getExtendedPropertiesValuesByName(Device.vcard_device_type_header)
.component1() .component1()
?.let { typeKey -> ?.let { typeKey ->
DeviceTypes.deviceTypeSupported(typeKey) DeviceTypes.deviceTypeSupported(typeKey)
} ?: false } ?: false ) else false
if (!validType) { if (!validType) {
Log.e("[Device] vCard validation : invalid type ${ Log.e("[Device] vCard validation : invalid type ${
card.getExtendedPropertiesValuesByName(Device.vcard_device_type_header).component1() card.getExtendedPropertiesValuesByName(Device.vcard_device_type_header)
}") }")
return false return false
} }
val validDtmf = card.getExtendedPropertiesValuesByName(Device.vcard_action_method_type_header) val validDtmf = if (card.getExtendedPropertiesValuesByName(Device.vcard_action_method_type_header).size == 1) card.getExtendedPropertiesValuesByName(Device.vcard_action_method_type_header)
.component1()?.let { remoteDtmfMethod -> .component1()?.let { remoteDtmfMethod ->
Device.vCardActionMethodsToDeviceMethods.get(remoteDtmfMethod)?.let { localDtmfMethod -> Device.vCardActionMethodsToDeviceMethods.get(remoteDtmfMethod)?.let { localDtmfMethod ->
ActionsMethodTypes.methodTypeIsSupported(localDtmfMethod) ActionsMethodTypes.methodTypeIsSupported(localDtmfMethod)
}?:false }?:false
}?:false }?:false else false
if (!validDtmf) { if (!validDtmf) {
Log.e("[Device] vCard validation : invalid dtmf sending method ${ Log.e("[Device] vCard validation : invalid dtmf sending method ${
card.getExtendedPropertiesValuesByName(Device.vcard_action_method_type_header) card.getExtendedPropertiesValuesByName(Device.vcard_action_method_type_header)
.component1()
}") }")
return false return false
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment