From f4481d74c4b11ad1f14783dcdfd1245cfd1bf8df Mon Sep 17 00:00:00 2001 From: Danny van Heumen Date: Fri, 22 Aug 2014 22:24:31 +0200 Subject: [PATCH] Restore ability to skip smiley replacement in URLs. --- .../gui/main/chat/ChatConversationPanel.java | 21 ++++++++++++------- .../impl/protocol/irc/MessageIrcImpl.java | 2 ++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java index 1c04cc609..452257a2b 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java @@ -2374,10 +2374,6 @@ private void processReplacementService(final ReplacementService service, int startMatchPosition = plainTextInHtmlMatcher.start(1); int endMatchPosition = plainTextInHtmlMatcher.end(1); - // The pattern might find URL's too, however links have already - // been processed by now, so it will at most find the anchor - // text. - // don't process nothing // or don't process already processed links content if (!StringUtils.isNullOrEmpty(plainTextAsHtml)) @@ -2388,7 +2384,15 @@ private void processReplacementService(final ReplacementService service, final String plaintext = StringEscapeUtils.unescapeHtml4(plainTextAsHtml); - processText(plaintext, buff, pattern, service); + + // Test whether this piece of content (exactly) matches a + // URL pattern. We should find at most a full URL text if it + // exists, since links have already been processed, so any + // URL is already wrapped in A-tags. + final boolean isURL = + URL_PATTERN.matcher(plaintext).matches(); + + processText(plaintext, buff, pattern, service, isURL); startPos = endMatchPosition; } @@ -2406,12 +2410,13 @@ private void processReplacementService(final ReplacementService service, * @param pattern the pattern for current replacement service, created * earlier so we don't create it for every text we check. * @param rService the replacement service. - * @param skipSmileys whether to skip processing smileys + * @param isURL whether this content matches the URL pattern */ private void processText(final String plainText, final StringBuilder msgBuff, final Pattern pattern, - final ReplacementService rService) + final ReplacementService rService, + final boolean isURL) { Matcher m = pattern.matcher(plainText); @@ -2442,7 +2447,7 @@ private void processText(final String plainText, { if (cfg.getBoolean(ReplacementProperty. getPropertyName("SMILEY"), - true)) + true) && !isURL) { msgBuff.append("