From: Stephen Boyd Date: Thu, 19 Nov 2009 19:44:46 +0000 (-0800) Subject: gitweb.js: fix null object exception in initials calculation X-Git-Tag: v1.6.6-rc1~7^2~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e42a05f75c9ff5d10d0b8f6784fc244873818a99;p=git.git 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 user@example.com 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 Acked-by: Jakub Narebski Signed-off-by: Junio C Hamano --- diff --git a/gitweb/gitweb.js b/gitweb/gitweb.js index 91b766e33..f1ba9ae52 100644 --- a/gitweb/gitweb.js +++ b/gitweb/gitweb.js @@ -566,8 +566,11 @@ function handleLine(commit, group) { if (group.numlines >= 2) { var fragment = document.createDocumentFragment(); var br = document.createElement("br"); - var text = document.createTextNode( - commit.author.match(/\b([A-Z])\B/g).join('')); + var match = commit.author.match(/\b([A-Z])\B/g); + if (match) { + var text = document.createTextNode( + match.join('')); + } if (br && text) { var elem = fragment || td_sha1; elem.appendChild(br);