From 36f7080a68134d63c3b892b2140735d801bcbc98 Mon Sep 17 00:00:00 2001 From: Hugues Malphettes Date: Sat, 18 Jan 2014 16:29:51 +0800 Subject: [PATCH] Comments maybe contain an empty text tag --- bits/70_xlsx.js | 4 +++- xlsx.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bits/70_xlsx.js b/bits/70_xlsx.js index b950d8d..3941e1c 100644 --- a/bits/70_xlsx.js +++ b/bits/70_xlsx.js @@ -499,7 +499,9 @@ function parseComments(data) { if(x === "" || x.trim() === "") return; var y = parsexmltag(x.match(/]*>/)[0]); var comment = { author: y.authorId && authors[y.authorId] ? authors[y.authorId] : undefined, ref: y.ref, guid: y.guid, texts:[] }; - x.match(/([^\u2603]*)<\/text>/m)[1].split('').forEach(function(r) { + var textMatch = x.match(/([^\u2603]*)<\/text>/m); + if (!textMatch || !textMatch[1]) return; // a comment may contain an empty text tag. + textMatch[1].split('').forEach(function(r) { if(r === "" || r.trim() === "") return; /* 18.4.12 t ST_Xstring */ var ct = r.match(matchtag('t')); diff --git a/xlsx.js b/xlsx.js index e747da0..ac664aa 100644 --- a/xlsx.js +++ b/xlsx.js @@ -1079,7 +1079,9 @@ function parseComments(data) { if(x === "" || x.trim() === "") return; var y = parsexmltag(x.match(/]*>/)[0]); var comment = { author: y.authorId && authors[y.authorId] ? authors[y.authorId] : undefined, ref: y.ref, guid: y.guid, texts:[] }; - x.match(/([^\u2603]*)<\/text>/m)[1].split('').forEach(function(r) { + var textMatch = x.match(/([^\u2603]*)<\/text>/m); + if (!textMatch || !textMatch[1]) return; // a comment may contain an empty text tag. + textMatch[1].split('').forEach(function(r) { if(r === "" || r.trim() === "") return; /* 18.4.12 t ST_Xstring */ var ct = r.match(matchtag('t'));