Fix snapshot saves refetching page instead of using passed html

This commit is contained in:
Adomas Venčkauskas 2018-12-12 10:59:58 +02:00
parent 9ed8bed778
commit ffbe44a159
4 changed files with 10 additions and 5 deletions

View file

@ -753,7 +753,7 @@ Zotero.Attachments = new function(){
if ((contentType === 'text/html' || contentType === 'application/xhtml+xml')
// Documents from XHR don't work here
&& document instanceof Ci.nsIDOMDocument) {
&& Zotero.Translate.DOMWrapper.unwrap(document) instanceof Ci.nsIDOMDocument) {
Zotero.debug('Saving document with saveDocument()');
yield Zotero.Utilities.Internal.saveDocument(document, tmpFile);
}

View file

@ -929,6 +929,7 @@ Zotero.Server.Connector.SaveSnapshot.prototype = {
var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
.createInstance(Components.interfaces.nsIDOMParser);
parser.init(null, Services.io.newURI(data.url));
var doc = parser.parseFromString(`<html>${data.html}</html>`, 'text/html');
doc = Zotero.HTTP.wrapDocument(doc, data.url);

View file

@ -462,7 +462,7 @@ Zotero.Utilities.Internal = {
wbp.progressListener = listener;
wbp.saveDocument(
document,
Zotero.Translate.DOMWrapper.unwrap(document),
Zotero.File.pathToFile(destFile),
Zotero.File.pathToFile(filesFolder),
null,

View file

@ -2121,9 +2121,13 @@ Zotero.WebProgressFinishListener = function(onFinish) {
let contentType = null;
try {
let r = _request || req;
_request.QueryInterface(Components.interfaces.nsIHttpChannel);
status = r.responseStatus;
contentType = r.contentType;
if (!r) {
Zotero.debug("WebProgressFinishListener: finished without a valid request")
} else {
r.QueryInterface(Components.interfaces.nsIHttpChannel);
status = r.responseStatus;
contentType = r.contentType;
}
}
catch (e) {
Zotero.debug(e, 2);