Skip to content

Commit e42a05f

Browse files
bebarinogitster
authored andcommitted
gitweb.js: fix null object exception in initials calculation
Currently handleLine() assumes that a commit author name will always start with a capital letter. It's possible that the author name is [email protected] and therefore calling a match() on the name will fail to return any matches. Subsequently joining these matches will cause an exception. Fix by checking that we have a match before trying to join the results into a set of initials for the author. Signed-off-by: Stephen Boyd <[email protected]> Acked-by: Jakub Narebski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 63267de commit e42a05f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

gitweb/gitweb.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,11 @@ function handleLine(commit, group) {
566566
if (group.numlines >= 2) {
567567
var fragment = document.createDocumentFragment();
568568
var br = document.createElement("br");
569-
var text = document.createTextNode(
570-
commit.author.match(/\b([A-Z])\B/g).join(''));
569+
var match = commit.author.match(/\b([A-Z])\B/g);
570+
if (match) {
571+
var text = document.createTextNode(
572+
match.join(''));
573+
}
571574
if (br && text) {
572575
var elem = fragment || td_sha1;
573576
elem.appendChild(br);

0 commit comments

Comments
 (0)