Limit HTTP status override to certain invalid HTTP responses

Only NS_ERROR_INVALID_CONTENT_ENCODING for now

For example, it shouldn't swap in a 403 on
NS_ERROR_PROXY_CONNECTION_REFUSED, as it was doing previously.

https://forums.zotero.org/discussion/81864/syncing-error
This commit is contained in:
Dan Stillman 2020-03-11 08:53:13 -04:00
parent b0de59fe89
commit 3129f35804
3 changed files with 15 additions and 12 deletions

View file

@ -4643,12 +4643,13 @@ Zotero.Item.prototype.migrateExtraFields = function () {
Zotero.debug("Item Type: " + itemType);
}
if (fields.size) {
Zotero.debug(Array.from(fields.entries()));
Zotero.debug("Fields:\n\n" + Array.from(fields.entries()).map(x => `${x[0]}: ${x[1]}`).join("\n"));
}
if (creators.length) {
Zotero.debug("Creators:");
Zotero.debug(creators);
}
Zotero.debug(extra);
Zotero.debug("Remaining Extra:\n\n" + extra);
return true;
}

View file

@ -417,13 +417,18 @@ Zotero.HTTP = new function() {
if (responseStatus >= 300 && responseStatus < 400) {
status = responseStatus;
}
// If an invalid HTTP response (e.g., NS_ERROR_INVALID_CONTENT_ENCODING) includes a
// 4xx or 5xx HTTP response code, swap it in, since it might be enough info to do
// what we need (e.g., verify a 404 from a WebDAV server)
// If an invalid HTTP response includes a 4xx or 5xx HTTP response code, swap it
// in, since it might be enough info to do what we need (e.g., verify a 404 from
// a WebDAV server)
else if (responseStatus >= 400) {
Zotero.warn(`Overriding status for invalid response for ${dispURL} `
+ `(${xmlhttp.channel.status})`);
status = responseStatus;
let statuses = [
2152398875, // NS_ERROR_INVALID_CONTENT_ENCODING
];
if (statuses.includes(xmlhttp.channel.status)) {
Zotero.warn(`Overriding status for invalid response for ${dispURL} `
+ `(${xmlhttp.channel.status})`);
status = responseStatus;
}
}
}
}

View file

@ -716,10 +716,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
yield Zotero.Retractions.init();
// Migrate fields from Extra that can be moved to item fields after a schema update
//
// Disabled for now
//
//yield Zotero.Schema.migrateExtraFields();
yield Zotero.Schema.migrateExtraFields();
// Load all library data except for items, which are loaded when libraries are first
// clicked on or if otherwise necessary