aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/juick/util/MessageUtils.java2
-rw-r--r--src/test/java/com/juick/MessageTest.java4
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java6
3 files changed, 5 insertions, 7 deletions
diff --git a/src/main/java/com/juick/util/MessageUtils.java b/src/main/java/com/juick/util/MessageUtils.java
index 316adb90..3c8001d8 100644
--- a/src/main/java/com/juick/util/MessageUtils.java
+++ b/src/main/java/com/juick/util/MessageUtils.java
@@ -57,7 +57,7 @@ public class MessageUtils {
private final static String urlWhiteSpacePrefix = "((?<=\\s)|(?<=\\A))";
- private final static String urlRegex = "((?:(?:ht|f)tps?://(?:www\\.)?([^\\s()<>/?#]+)([^\\s()<>]*)?))";
+ private final static String urlRegex = "((?:(?:ht|f)tps?://(?:www\\.)?([^\\s()<>/?#]+)([^\\s()<>«»]*)?))";
private final static String urlWithWhitespacesRegex =
urlWhiteSpacePrefix + urlRegex;
diff --git a/src/test/java/com/juick/MessageTest.java b/src/test/java/com/juick/MessageTest.java
index 6ce01f4a..e750f652 100644
--- a/src/test/java/com/juick/MessageTest.java
+++ b/src/test/java/com/juick/MessageTest.java
@@ -243,7 +243,11 @@ public class MessageTest {
var safeMessage = "And that is a [odd](https://juick.com/a/1)? aaapaa";
var nonsafeMessage = "[Here is my link](https://juick.com?hash=12345)";
var filteredMessage = "[Here is my link](https://juick.com)";
+ var pidginMessage = "I'm very smart to post my login url there<https://juick.com/settings?hash=VTYZkKV8FWkmu6g1>";
+ var westernMessage = "«Please, verify your account at https://juick.com/settings?hash=12345»";
assertThat(MessageUtils.stripNonSafeUrls(safeMessage), is(safeMessage));
assertThat(MessageUtils.stripNonSafeUrls(nonsafeMessage), is(filteredMessage));
+ assertThat(MessageUtils.stripNonSafeUrls(pidginMessage), not(containsString("VTYZkKV8FWkmu6g1")));
+ assertThat(MessageUtils.stripNonSafeUrls(westernMessage), containsString("»"));
}
}
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index e0abe136..d0f4032a 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -913,12 +913,6 @@ public class ServerTests {
assertThat(result.getNewMessage(), is(Optional.empty()));
assertThat(result.getText(), is("Tags are NOT updated (5 tags maximum?)"));
result = commandsManager.processCommand(user,
- "I'm very smart to post my login url there"
- + "<https://juick.com/settings?hash=VTYZkKV8FWkmu6g1>",
- emptyUri);
- assertThat(result.getNewMessage().isPresent(), is(true));
- assertFalse(result.getNewMessage().get().getText().contains("VTYZkKV8FWkmu6g1"));
- result = commandsManager.processCommand(user,
"*корм *juick_ppl *рационализм *? *мюсли а сколько микроморт в дневной порции сверхмюслей?",
emptyUri);
assertThat(result.getNewMessage().isPresent(), is(true));