From c1455ee99481868899ab7e1f7d49d15205795d32 Mon Sep 17 00:00:00 2001 From: Gwendal Roulleau Date: Wed, 8 Jun 2022 09:07:47 +0200 Subject: [PATCH] [smsmodem] Fix sender identifier error with special character Signed-off-by: Gwendal Roulleau --- .../internal/SMSConversationDiscoveryService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/SMSConversationDiscoveryService.java b/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/SMSConversationDiscoveryService.java index 254b69ee964f5..6b8b9db33e038 100644 --- a/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/SMSConversationDiscoveryService.java +++ b/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/SMSConversationDiscoveryService.java @@ -54,12 +54,13 @@ protected void startScan() { } } - public void buildDiscovery(String msisdn) { + public void buildDiscovery(String sender) { + String senderSanitized = sender.replaceAll("[^a-zA-Z0-9+]", "_"); ThingUID thingUID = SMSModemHandlerFactory - .getSMSConversationUID(SMSModemBindingConstants.SMSCONVERSATION_THING_TYPE, msisdn, bridgeUid); + .getSMSConversationUID(SMSModemBindingConstants.SMSCONVERSATION_THING_TYPE, senderSanitized, bridgeUid); DiscoveryResult result = DiscoveryResultBuilder.create(thingUID) - .withProperty(SMSModemBindingConstants.SMSCONVERSATION_PARAMETER_RECIPIENT, msisdn) - .withLabel("Conversation with " + msisdn).withBridge(bridgeUid) + .withProperty(SMSModemBindingConstants.SMSCONVERSATION_PARAMETER_RECIPIENT, senderSanitized) + .withLabel("Conversation with " + sender).withBridge(bridgeUid) .withThingType(SMSModemBindingConstants.SMSCONVERSATION_THING_TYPE) .withRepresentationProperty(SMSModemBindingConstants.SMSCONVERSATION_PARAMETER_RECIPIENT).build(); thingDiscovered(result);