summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Matthys <glenn@webmind.be>2016-01-08 12:48:47 +0100
committerFlorian Zschocke <florian.zschocke@devolo.de>2016-12-10 12:43:36 +0100
commit0e4eebcfd98d079c93c33510284cdfe976e27725 (patch)
treeaf20823165faed2c40576c7126f6aa7ba2c261d3
parenta1d8cfcf60bf23136512afad95edc3faede7108c (diff)
downloadgitblit-0e4eebcfd98d079c93c33510284cdfe976e27725.tar.gz
gitblit-0e4eebcfd98d079c93c33510284cdfe976e27725.zip
Use REGEX_TICKET_MENTION instead of hardcoded regular expression
-rw-r--r--src/main/java/com/gitblit/models/TicketModel.java4
-rw-r--r--src/main/java/com/gitblit/tickets/TicketNotifier.java2
-rw-r--r--src/main/java/com/gitblit/utils/MarkdownUtils.java3
3 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/com/gitblit/models/TicketModel.java b/src/main/java/com/gitblit/models/TicketModel.java
index d5345891..924400f5 100644
--- a/src/main/java/com/gitblit/models/TicketModel.java
+++ b/src/main/java/com/gitblit/models/TicketModel.java
@@ -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);
diff --git a/src/main/java/com/gitblit/tickets/TicketNotifier.java b/src/main/java/com/gitblit/tickets/TicketNotifier.java
index 8c7fe6d4..1d7e4f24 100644
--- a/src/main/java/com/gitblit/tickets/TicketNotifier.java
+++ b/src/main/java/com/gitblit/tickets/TicketNotifier.java
@@ -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();
diff --git a/src/main/java/com/gitblit/utils/MarkdownUtils.java b/src/main/java/com/gitblit/utils/MarkdownUtils.java
index e0c9dd4e..794d54ab 100644
--- a/src/main/java/com/gitblit/utils/MarkdownUtils.java
+++ b/src/main/java/com/gitblit/utils/MarkdownUtils.java
@@ -30,6 +30,7 @@ import org.pegdown.ParsingTimeoutException;
import org.pegdown.PegDownProcessor;
import org.pegdown.ast.RootNode;
+import com.gitblit.Constants;
import com.gitblit.IStoredSettings;
import com.gitblit.Keys;
import com.gitblit.wicket.MarkupProcessor.WorkaroundHtmlSerializer;
@@ -138,7 +139,7 @@ public class MarkdownUtils {
// emphasize and link mentions
String mentionReplacement = String.format(" **[@$1](%1s/user/$1)**", canonicalUrl);
- text = text.replaceAll("\\s@([A-Za-z0-9-_]+)", mentionReplacement);
+ text = text.replaceAll(Constants.REGEX_TICKET_MENTION, mentionReplacement);
// link ticket refs
String ticketReplacement = MessageFormat.format("$1[#$2]({0}/tickets?r={1}&h=$2)$3", canonicalUrl, repositoryName);