Skip to content

Commit

Permalink
gitweb.js: fix null object exception in initials calculation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Boyd authored and Junio C Hamano committed Nov 20, 2009
1 parent 63267de commit e42a05f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gitweb/gitweb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e42a05f

Please sign in to comment.