diff options
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/gitblit/models/Activity.java | 4 | ||||
-rw-r--r-- | src/com/gitblit/utils/MetricUtils.java | 1 | ||||
-rw-r--r-- | src/com/gitblit/utils/StringUtils.java | 14 | ||||
-rw-r--r-- | src/com/gitblit/wicket/pages/RepositoryPage.java | 2 |
4 files changed, 19 insertions, 2 deletions
diff --git a/src/com/gitblit/models/Activity.java b/src/com/gitblit/models/Activity.java index 771c8a1a..7e0cb4b3 100644 --- a/src/com/gitblit/models/Activity.java +++ b/src/com/gitblit/models/Activity.java @@ -28,6 +28,7 @@ import java.util.Set; import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.revwalk.RevCommit;
+import com.gitblit.utils.StringUtils;
import com.gitblit.utils.TimeUtils;
/**
@@ -93,8 +94,7 @@ public class Activity implements Serializable, Comparable<Activity> { }
repositoryMetrics.get(repository).count++;
- String author = commit.getAuthorIdent().getEmailAddress()
- .toLowerCase();
+ String author = StringUtils.removeNewlines(commit.getAuthorIdent().getEmailAddress()).toLowerCase();
if (!authorMetrics.containsKey(author)) {
authorMetrics.put(author, new Metric(author));
}
diff --git a/src/com/gitblit/utils/MetricUtils.java b/src/com/gitblit/utils/MetricUtils.java index e9e1fa52..26e4581c 100644 --- a/src/com/gitblit/utils/MetricUtils.java +++ b/src/com/gitblit/utils/MetricUtils.java @@ -210,6 +210,7 @@ public class MetricUtils { p = rev.getAuthorIdent().getEmailAddress().toLowerCase();
}
}
+ p = p.replace('\n',' ').replace('\r', ' ').trim();
if (!metricMap.containsKey(p)) {
metricMap.put(p, new Metric(p));
}
diff --git a/src/com/gitblit/utils/StringUtils.java b/src/com/gitblit/utils/StringUtils.java index 86840048..86823db5 100644 --- a/src/com/gitblit/utils/StringUtils.java +++ b/src/com/gitblit/utils/StringUtils.java @@ -719,4 +719,18 @@ public class StringUtils { Matcher m = p.matcher(input);
return m.matches();
}
+
+ /**
+ * Removes new line and carriage return chars from a string.
+ * If input value is null an empty string is returned.
+ *
+ * @param input
+ * @return a sanitized or empty string
+ */
+ public static String removeNewlines(String input) {
+ if (input == null) {
+ return "";
+ }
+ return input.replace('\n',' ').replace('\r', ' ').trim();
+ }
}
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.java b/src/com/gitblit/wicket/pages/RepositoryPage.java index b4e1a0e3..897e2001 100644 --- a/src/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/com/gitblit/wicket/pages/RepositoryPage.java @@ -450,6 +450,8 @@ public abstract class RepositoryPage extends BasePage { Constants.SearchType searchType) {
String name = identity == null ? "" : identity.getName();
String address = identity == null ? "" : identity.getEmailAddress();
+ name = StringUtils.removeNewlines(name);
+ address = StringUtils.removeNewlines(address);
boolean showEmail = GitBlit.getBoolean(Keys.web.showEmailAddresses, false);
if (!showEmail || StringUtils.isEmpty(name) || StringUtils.isEmpty(address)) {
String value = name;
|