Harden metrics from polluted data (issue-176)
| | |
| | |
|
| | | #### fixes
|
| | |
|
| | | - Author metrics can be broken by newlines in email addresses from converted repositories (issue 176)
|
| | | - Set subjectAlternativeName on generated SSL cert if CN is an ip address (issue 170)
|
| | | - Fixed incorrect links on history page for files not in the current/active commit (issue 166)
|
| | | - Empty repository page failed to handle missing repository (issue 160)
|
| | |
| | | import org.eclipse.jgit.lib.PersonIdent;
|
| | | import org.eclipse.jgit.revwalk.RevCommit;
|
| | |
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.utils.TimeUtils;
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | | 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));
|
| | | }
|
| | |
| | | p = rev.getAuthorIdent().getEmailAddress().toLowerCase();
|
| | | }
|
| | | }
|
| | | p = p.replace('\n',' ').replace('\r', ' ').trim();
|
| | | if (!metricMap.containsKey(p)) {
|
| | | metricMap.put(p, new Metric(p));
|
| | | }
|
| | |
| | | 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();
|
| | | }
|
| | | } |
| | |
| | | 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;
|