From 71c0f30ae515d66b059df6400ae5149f7a45779f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Berg?= Date: Tue, 30 Mar 2010 14:33:49 +0200 Subject: [PATCH] Stability: employ more sanity checks when parsing author details from history.js --- html/views/history/history.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/html/views/history/history.js b/html/views/history/history.js index ab06b4f..eabcf41 100644 --- a/html/views/history/history.js +++ b/html/views/history/history.js @@ -32,15 +32,25 @@ var Commit = function(obj) { } this.header = this.raw.substring(0, messageStart); - var match = this.header.match(/\nauthor (.*) <(.*@.*|.*)> ([0-9].*)/); - if (!(match[2].match(/@[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/))) - this.author_email = match[2]; + if (typeof this.header !== 'undefined') { + var match = this.header.match(/\nauthor (.*) <(.*@.*|.*)> ([0-9].*)/); + if (typeof match !== 'undefined' && typeof match[2] !== 'undefined') { + if (!(match[2].match(/@[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/))) + this.author_email = match[2]; + + this.author_date = new Date(parseInt(match[3]) * 1000); + + match = this.header.match(/\ncommitter (.*) <(.*@.*|.*)> ([0-9].*)/); + if (typeof match !== 'undefined') { + this.committer_name = match[1]; + this.committer_email = match[2]; + } else { + this.committer_name = "undefined"; + this.committer_email = "undefined"; + } + } + } - this.author_date = new Date(parseInt(match[3]) * 1000); - - match = this.header.match(/\ncommitter (.*) <(.*@.*|.*)> ([0-9].*)/); - this.committer_name = match[1]; - this.committer_email = match[2]; this.committer_date = new Date(parseInt(match[3]) * 1000); }