From c54aaeb43a7941317c1f3c119ffa92090f988820 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 19 Sep 2025 11:15:02 +0100 Subject: Disable external file access by default --- test/mammoth.tests.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/mammoth.tests.js b/test/mammoth.tests.js index 06cf62f..038cbdf 100644 --- a/test/mammoth.tests.js +++ b/test/mammoth.tests.js @@ -309,27 +309,27 @@ test('src of inline images can be changed using readAsBuffer()', function() { }); }); -test('images stored outside of document are included in output', function() { +test('when external file access is enabled then images stored outside of document are included in output', function() { var docxPath = path.join(__dirname, "test-data/external-picture.docx"); - return mammoth.convertToHtml({path: docxPath}).then(function(result) { + return mammoth.convertToHtml({path: docxPath}, {externalFileAccess: true}).then(function(result) { assert.equal(result.value, '

'); assert.deepEqual(result.messages, []); }); }); -test('error if images stored outside of document are specified when passing file without path', function() { +test('when external file access is enabled then error if images stored outside of document are specified when passing file without path', function() { var docxPath = path.join(__dirname, "test-data/external-picture.docx"); var buffer = fs.readFileSync(docxPath); - return mammoth.convertToHtml({buffer: buffer}).then(function(result) { + return mammoth.convertToHtml({buffer: buffer}, {externalFileAccess: true}).then(function(result) { assert.equal(result.value, ''); assert.equal(result.messages[0].message, "could not find external image 'tiny-picture.png', path of input document is unknown"); assert.equal(result.messages[0].type, "error"); }); }); -test('error if images stored outside of document are specified when external file access is disabled', function() { +test('given external file access is disabled by default then error if images stored outside of document are specified', function() { var docxPath = path.join(__dirname, "test-data/external-picture.docx"); - return mammoth.convertToHtml({path: docxPath}, {externalFileAccess: false}).then(function(result) { + return mammoth.convertToHtml({path: docxPath}).then(function(result) { assert.equal(result.value, ''); assert.equal(result.messages[0].message, "could not read external image 'tiny-picture.png', external file access is disabled"); assert.equal(result.messages[0].type, "error"); -- cgit v1.2.3