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 <bebarino@gmail.com> Acked-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stephen Boyd committed
Nov 19, 2009 at 11:44 UTC
e42a05f75c9ff5d10d0b8f6784fc244873818a99
1 file changed
+5
-2
gitweb/gitweb.js
+5
-2
@@ -566,8 +566,11 @@ function handleLine(commit, group) {
566
if (group.numlines >= 2) {
567
var fragment = document.createDocumentFragment();
568
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
+ }
574
if (br && text) {
575
var elem = fragment || td_sha1;
576
elem.appendChild(br);