From c16598a545c8ee2d36c183affbc2906cbef4f128 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 23 Jan 2019 13:27:40 +0300 Subject: quote formatting fixes and more test cases --- src/main/java/com/juick/util/MessageUtils.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main') 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("<", "<"); msg = msg.replaceAll(">", ">"); - // > citate - msg = msg.replaceAll(citateRegex, "$1"); - msg = msg.replaceAll("", "\n"); + // -- // — msg = msg.replaceAll("((?<=\\s)|(?<=\\A))\\-\\-?((?=\\s)|(?=\\Z))", "$1—$2"); @@ -207,6 +206,10 @@ public class MessageUtils { m.appendTail(sb); msg = sb.toString(); + // > citate + msg = msg.replaceAll(citateRegex, "$1"); + msg = msg.replaceAll("", "\n"); + msg = msg.replaceAll("\n", "
\n"); return msg; } -- cgit v1.2.3