aboutsummaryrefslogtreecommitdiff
path: root/test/mammoth.tests.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-09-19 11:15:02 +0100
committerMichael Williamson <mike@zwobble.org>2025-09-19 11:15:02 +0100
commitc54aaeb43a7941317c1f3c119ffa92090f988820 (patch)
treef0598b4597e9d9e8f16120563a79839b845ca611 /test/mammoth.tests.js
parentc6f51699f86176276ffc6d22f2cd0a2b1c592c3e (diff)
Disable external file access by default
Diffstat (limited to 'test/mammoth.tests.js')
-rw-r--r--test/mammoth.tests.js12
1 files changed, 6 insertions, 6 deletions
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, '<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAOvgAADr4B6kKxwAAAABNJREFUKFNj/M+ADzDhlWUYqdIAQSwBE8U+X40AAAAASUVORK5CYII=" /></p>');
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");