]> source.dussan.org Git - gitblit.git/commitdiff
Use REGEX_TICKET_MENTION instead of hardcoded regular expression
authorGlenn Matthys <glenn@webmind.be>
Fri, 8 Jan 2016 11:48:47 +0000 (12:48 +0100)
committerFlorian Zschocke <florian.zschocke@devolo.de>
Sat, 10 Dec 2016 11:43:36 +0000 (12:43 +0100)
src/main/java/com/gitblit/models/TicketModel.java
src/main/java/com/gitblit/tickets/TicketNotifier.java
src/main/java/com/gitblit/utils/MarkdownUtils.java

index d5345891974982f3e2c52fc4030ba93b48adbee6..924400f5375e9825c54c238ddf87965481935f1b 100644 (file)
@@ -43,6 +43,8 @@ import java.util.regex.Pattern;
 
 import org.eclipse.jgit.util.RelativeDateFormatter;
 
+import com.gitblit.Constants;
+
 /**
  * The Gitblit Ticket model, its component classes, and enums.
  *
@@ -773,7 +775,7 @@ public class TicketModel implements Serializable, Comparable<TicketModel> {
                        }
                        
                        try {
-                               Pattern mentions = Pattern.compile("\\s@([A-Za-z0-9-_]+)");
+                               Pattern mentions = Pattern.compile(Constants.REGEX_TICKET_MENTION);
                                Matcher m = mentions.matcher(text);
                                while (m.find()) {
                                        String username = m.group(1);
index 8c7fe6d46a2f15c20449cd7cc59a0153dce8527c..1d7e4f243e4fcbbcbb45c24a45ad528b17a6e7b1 100644 (file)
@@ -573,7 +573,7 @@ public class TicketNotifier {
                // cc users mentioned in last comment
                Change lastChange = ticket.changes.get(ticket.changes.size() - 1);
                if (lastChange.hasComment()) {
-                       Pattern p = Pattern.compile("\\s@([A-Za-z0-9-_]+)");
+                       Pattern p = Pattern.compile(Constants.REGEX_TICKET_MENTION);
                        Matcher m = p.matcher(lastChange.comment.text);
                        while (m.find()) {
                                String username = m.group();
index e0c9dd4e7e5b8d3850aa41e766b7c074876286b7..794d54ab189aee99b30877a373322a146dcf1743 100644 (file)
@@ -30,6 +30,7 @@ import org.pegdown.ParsingTimeoutException;
 import org.pegdown.PegDownProcessor;\r
 import org.pegdown.ast.RootNode;\r
 \r
+import com.gitblit.Constants;\r
 import com.gitblit.IStoredSettings;\r
 import com.gitblit.Keys;\r
 import com.gitblit.wicket.MarkupProcessor.WorkaroundHtmlSerializer;\r
@@ -138,7 +139,7 @@ public class MarkdownUtils {
 \r
                // emphasize and link mentions\r
                String mentionReplacement = String.format(" **[@$1](%1s/user/$1)**", canonicalUrl);\r
-               text = text.replaceAll("\\s@([A-Za-z0-9-_]+)", mentionReplacement);\r
+               text = text.replaceAll(Constants.REGEX_TICKET_MENTION, mentionReplacement);\r
 \r
                // link ticket refs
                String ticketReplacement = MessageFormat.format("$1[#$2]({0}/tickets?r={1}&h=$2)$3", canonicalUrl, repositoryName);