From b48f1c1925cb77664615e11470458b1dae2ac09b Mon Sep 17 00:00:00 2001 From: Feras Almannaa Date: Sun, 29 Sep 2019 16:06:37 +0300 Subject: [PATCH] [rest] Allow colons and dashes in sse topic filter validator (#1052) Fixes #1043 Signed-off-by: Feras Almanna --- .../eclipse/smarthome/io/rest/sse/internal/util/SseUtil.java | 2 +- .../smarthome/io/rest/sse/internal/util/SseUtilTest.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.core.io.rest.sse/src/main/java/org/eclipse/smarthome/io/rest/sse/internal/util/SseUtil.java b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/eclipse/smarthome/io/rest/sse/internal/util/SseUtil.java index d2d086a85f..1c339c82e6 100644 --- a/bundles/org.openhab.core.io.rest.sse/src/main/java/org/eclipse/smarthome/io/rest/sse/internal/util/SseUtil.java +++ b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/eclipse/smarthome/io/rest/sse/internal/util/SseUtil.java @@ -30,7 +30,7 @@ import org.glassfish.jersey.media.sse.OutboundEvent; * @author Dennis Nobel - Changed EventBean */ public class SseUtil { - static final String TOPIC_VALIDATE_PATTERN = "(\\w*\\*?\\/?,?\\s*)*"; + static final String TOPIC_VALIDATE_PATTERN = "(\\w*\\*?\\/?,?:?-?\\s*)*"; /** * Creates a new {@link OutboundEvent} object containing an {@link EventBean} created for the given Eclipse diff --git a/bundles/org.openhab.core.io.rest.sse/src/test/java/org/eclipse/smarthome/io/rest/sse/internal/util/SseUtilTest.java b/bundles/org.openhab.core.io.rest.sse/src/test/java/org/eclipse/smarthome/io/rest/sse/internal/util/SseUtilTest.java index 1f5e70215e..add90b6328 100644 --- a/bundles/org.openhab.core.io.rest.sse/src/test/java/org/eclipse/smarthome/io/rest/sse/internal/util/SseUtilTest.java +++ b/bundles/org.openhab.core.io.rest.sse/src/test/java/org/eclipse/smarthome/io/rest/sse/internal/util/SseUtilTest.java @@ -52,6 +52,8 @@ public class SseUtilTest { assertThat(SseUtil.isValidTopicFilter("////////////"), is(true)); assertThat(SseUtil.isValidTopicFilter("*/added"), is(true)); assertThat(SseUtil.isValidTopicFilter("*added"), is(true)); + assertThat(SseUtil.isValidTopicFilter("smarthome/test/test:test:123/test"), is(true)); + assertThat(SseUtil.isValidTopicFilter("smarthome/test/test-test-123-test:test:123/test"), is(true)); } @Test