Skip to content

Commit 71c0f30

Browse files
andrebergbrotherbard
authored andcommitted
Stability: employ more sanity checks when parsing author details from history.js
1 parent fffa024 commit 71c0f30

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

html/views/history/history.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,25 @@ var Commit = function(obj) {
3232
}
3333
this.header = this.raw.substring(0, messageStart);
3434

35-
var match = this.header.match(/\nauthor (.*) <(.*@.*|.*)> ([0-9].*)/);
36-
if (!(match[2].match(/@[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/)))
37-
this.author_email = match[2];
35+
if (typeof this.header !== 'undefined') {
36+
var match = this.header.match(/\nauthor (.*) <(.*@.*|.*)> ([0-9].*)/);
37+
if (typeof match !== 'undefined' && typeof match[2] !== 'undefined') {
38+
if (!(match[2].match(/@[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/)))
39+
this.author_email = match[2];
40+
41+
this.author_date = new Date(parseInt(match[3]) * 1000);
42+
43+
match = this.header.match(/\ncommitter (.*) <(.*@.*|.*)> ([0-9].*)/);
44+
if (typeof match !== 'undefined') {
45+
this.committer_name = match[1];
46+
this.committer_email = match[2];
47+
} else {
48+
this.committer_name = "undefined";
49+
this.committer_email = "undefined";
50+
}
51+
}
52+
}
3853

39-
this.author_date = new Date(parseInt(match[3]) * 1000);
40-
41-
match = this.header.match(/\ncommitter (.*) <(.*@.*|.*)> ([0-9].*)/);
42-
this.committer_name = match[1];
43-
this.committer_email = match[2];
4454
this.committer_date = new Date(parseInt(match[3]) * 1000);
4555
}
4656

0 commit comments

Comments
 (0)