From b01260294e204f7c128ba6ae81ec4f4d3d61a298 Mon Sep 17 00:00:00 2001 From: John Shearer Date: Thu, 10 Nov 2022 10:35:49 +0000 Subject: [PATCH] Truncate stream names to 31 characters fixes https://github.com/SheetJS/js-cfb/issues/18 --- bits/66_dir.js | 6 +++--- cfb.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bits/66_dir.js b/bits/66_dir.js index 4ef383c..fb83cb1 100644 --- a/bits/66_dir.js +++ b/bits/66_dir.js @@ -9,9 +9,9 @@ file = cfb.FileIndex[i]; if(i === 0) file.start = file.size ? file.start - 1 : ENDOFCHAIN; var _nm/*:string*/ = (i === 0 && _opts.root) || file.name; - if(_nm.length > 32) { - console.error("Name " + _nm + " will be truncated to " + _nm.slice(0,32)); - _nm = _nm.slice(0, 32); + if(_nm.length > 31) { + console.error("Name " + _nm + " will be truncated to " + _nm.slice(0,31)); + _nm = _nm.slice(0, 31); } flen = 2*(_nm.length+1); o.write_shift(64, _nm, "utf16le"); diff --git a/cfb.js b/cfb.js index dec6197..d04a9cb 100644 --- a/cfb.js +++ b/cfb.js @@ -891,9 +891,9 @@ flen = file.content.length; file = cfb.FileIndex[i]; if(i === 0) file.start = file.size ? file.start - 1 : ENDOFCHAIN; var _nm = (i === 0 && _opts.root) || file.name; - if(_nm.length > 32) { - console.error("Name " + _nm + " will be truncated to " + _nm.slice(0,32)); - _nm = _nm.slice(0, 32); + if(_nm.length > 31) { + console.error("Name " + _nm + " will be truncated to " + _nm.slice(0,31)); + _nm = _nm.slice(0, 31); } flen = 2*(_nm.length+1); o.write_shift(64, _nm, "utf16le");