Skip to content

Commit

Permalink
gitweb.js: Harden setting blamed commit info in incremental blame
Browse files Browse the repository at this point in the history
Internet Explorer 8 stops at beginning of blame filling with the
following bug:

  "firstChild is null or not an object"

at this line:

  a_sha1.firstChild.data = commit.sha1.substr(0, 8);

It is (probably) caused by the fact that while a_sha1 element, which
looks like this:

  <a href=""> </a>

It has a firstChild which is a text node containing only whitespace
(single space character) in other web browsers (Firefox 3.5, Opera 10,
Google Chrome 3.0), IE8 clobbers DOM, removing trailing/leading
whitespace.

Protect against this bug by creating text element if it does not
exist.

Found-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jakub Narebski authored and Junio C Hamano committed Nov 25, 2009
1 parent e42a05f commit 6aa2de5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gitweb/gitweb.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,12 @@ function handleLine(commit, group) {
td_sha1.rowSpan = group.numlines;

a_sha1.href = projectUrl + 'a=commit;h=' + commit.sha1;
a_sha1.firstChild.data = commit.sha1.substr(0, 8);
if (a_sha1.firstChild) {
a_sha1.firstChild.data = commit.sha1.substr(0, 8);
} else {
a_sha1.appendChild(
document.createTextNode(commit.sha1.substr(0, 8)));
}
if (group.numlines >= 2) {
var fragment = document.createDocumentFragment();
var br = document.createElement("br");
Expand Down

0 comments on commit 6aa2de5

Please sign in to comment.