aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/util
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-01-23 13:27:40 +0300
committerGravatar Vitaly Takmazov2019-01-23 13:27:40 +0300
commitc16598a545c8ee2d36c183affbc2906cbef4f128 (patch)
tree035c1a19899191c0cd8aea37a490a9a747362b5b /src/main/java/com/juick/util
parente4f45130797df9dc94d10fd1c79ad8952c6390c1 (diff)
quote formatting fixes and more test cases
Diffstat (limited to 'src/main/java/com/juick/util')
-rw-r--r--src/main/java/com/juick/util/MessageUtils.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/com/juick/util/MessageUtils.java b/src/main/java/com/juick/util/MessageUtils.java
index 72c9bd04..dd9db293 100644
--- a/src/main/java/com/juick/util/MessageUtils.java
+++ b/src/main/java/com/juick/util/MessageUtils.java
@@ -144,12 +144,11 @@ public class MessageUtils {
}
public static String formatMessage(String msg) {
+
msg = msg.replaceAll("&", "&");
msg = msg.replaceAll("<", "&lt;");
msg = msg.replaceAll(">", "&gt;");
- // > citate
- msg = msg.replaceAll(citateRegex, "<q>$1</q>");
- msg = msg.replaceAll("</q><q>", "\n");
+
// --
// &mdash;
msg = msg.replaceAll("((?<=\\s)|(?<=\\A))\\-\\-?((?=\\s)|(?=\\Z))", "$1&mdash;$2");
@@ -207,6 +206,10 @@ public class MessageUtils {
m.appendTail(sb);
msg = sb.toString();
+ // > citate
+ msg = msg.replaceAll(citateRegex, "<q>$1</q>");
+ msg = msg.replaceAll("</q><q>", "\n");
+
msg = msg.replaceAll("\n", "<br/>\n");
return msg;
}