Disable JS in hidden browser when indexing HTML files without a charset

This could cause imports that linked to HTML files to hang, possibly
from network requests that failed.
This commit is contained in:
Dan Stillman 2018-06-18 20:17:37 -04:00
parent 9b9fe098d9
commit 2a7f31813e
4 changed files with 40 additions and 3 deletions

View file

@ -149,6 +149,25 @@ describe("Zotero.Attachments", function() {
assert.lengthOf(matches, 1);
assert.propertyVal(matches[0], 'id', attachment.id);
});
// This isn't particularly the behavior we want, but it documents the expected behavior
it("shouldn't index JavaScript-created text in an HTML file when the charset isn't known in advance", async function () {
var item = await createDataObject('item');
var file = getTestDataDirectory();
file.append('test-js.html');
var attachment = await Zotero.Attachments.importSnapshotFromFile({
title: 'Snapshot',
url: 'http://example.com',
file,
parentItemID: item.id,
contentType: 'text/html'
});
assert.equal(attachment.attachmentCharset, 'utf-8');
var matches = await Zotero.Fulltext.findTextInItems([attachment.id], 'test');
assert.lengthOf(matches, 0);
});
});
describe("#linkFromDocument", function () {