Skip to content

Commit 6aa2de5

Browse files
jnarebgitster
authored andcommitted
gitweb.js: Harden setting blamed commit info in incremental blame
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 <[email protected]> Signed-off-by: Jakub Narebski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e42a05f commit 6aa2de5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

gitweb/gitweb.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,12 @@ function handleLine(commit, group) {
562562
td_sha1.rowSpan = group.numlines;
563563

564564
a_sha1.href = projectUrl + 'a=commit;h=' + commit.sha1;
565-
a_sha1.firstChild.data = commit.sha1.substr(0, 8);
565+
if (a_sha1.firstChild) {
566+
a_sha1.firstChild.data = commit.sha1.substr(0, 8);
567+
} else {
568+
a_sha1.appendChild(
569+
document.createTextNode(commit.sha1.substr(0, 8)));
570+
}
566571
if (group.numlines >= 2) {
567572
var fragment = document.createDocumentFragment();
568573
var br = document.createElement("br");

0 commit comments

Comments
 (0)