Fix bug for empty title when a translator does not provide one.

This commit is contained in:
Fletcher Hazlehurst 2020-10-28 09:12:21 -06:00
parent a2620b757d
commit c0ec91f26d

View file

@ -869,6 +869,15 @@ Zotero.Attachments = new function(){
if (parentItemID && collections) {
throw new Error("parentItemID and parentCollectionIDs cannot both be provided");
}
// If no title was provided, pull it from the document
if (!title) {
let parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
.createInstance(Components.interfaces.nsIDOMParser);
parser.init(null, Services.io.newURI(url));
let doc = parser.parseFromString(snapshotContent, 'text/html');
title = doc.title;
}
let tmpDirectory = (await this.createTemporaryStorageDirectory()).path;
let destDirectory;