From 1695469b2c2d0f72ef63ad72070a464e42b2086a Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Wed, 15 Feb 2023 23:56:05 +0300
Subject: Parse old Pidgin urls
---
src/main/java/com/juick/util/MessageUtils.java | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
(limited to 'src/main/java')
diff --git a/src/main/java/com/juick/util/MessageUtils.java b/src/main/java/com/juick/util/MessageUtils.java
index 3651540e..a04dc24f 100644
--- a/src/main/java/com/juick/util/MessageUtils.java
+++ b/src/main/java/com/juick/util/MessageUtils.java
@@ -68,7 +68,7 @@ public class MessageUtils {
private final static String urlWithWhitespacesRegex =
urlWhiteSpacePrefix + urlRegex;
- private final static Pattern regexLinks2 = Pattern.compile("((?<=\\s)|(?<=\\A))([\\[\\{]|<)((?:ht|f)tps?:\\/\\/(?:www\\.)?([^\\/\\s\\\"\\)\\!>]*)\\/?(?:[^\\]\\}](?]+)\\*((?=\\s)|(?=\\Z)|(?=\\p{Punct}))";
private final static String italicRegex = "((?<=\\s)|(?<=\\A))/([^\\/\\n<>]+)/((?=\\s)|(?=\\Z)|(?=\\p{Punct}))";
@@ -169,9 +169,11 @@ public class MessageUtils {
// [link text][http://juick.com/last?page=2]
// [link text](http://juick.com/last?page=2)
+ // www.juick.com
// link text
msg = msg.replaceAll(textUrlRegex, "$1");
msg = msg.replaceAll(textUrlRegex2, "$1");
+ msg = msg.replaceAll(pidginUrlRegex, "$1");
// #12345
// #12345
@@ -218,7 +220,7 @@ public class MessageUtils {
Matcher m = regexLinks2.matcher(msg);
StringBuffer sb = new StringBuffer();
while (m.find()) {
- String url = m.group(3).replace(" ", "%20").replaceAll("\\s+", StringUtils.EMPTY);
+ String url = m.group(3).replace(" ", "%20").replace("$", "%36").replaceAll("\\s+", StringUtils.EMPTY);
m.appendReplacement(sb, "$1$2$4$5");
}
m.appendTail(sb);
--
cgit v1.2.3