From 3129f358046937f17fbbc45c3f16ac84b4508db0 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 11 Mar 2020 08:53:13 -0400 Subject: [PATCH] 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 --- chrome/content/zotero/xpcom/data/item.js | 5 +++-- chrome/content/zotero/xpcom/http.js | 17 +++++++++++------ chrome/content/zotero/xpcom/zotero.js | 5 +---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index f5a1fed28c..7c74b8289f 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -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; } diff --git a/chrome/content/zotero/xpcom/http.js b/chrome/content/zotero/xpcom/http.js index 47ecd14625..a8a5d220b2 100644 --- a/chrome/content/zotero/xpcom/http.js +++ b/chrome/content/zotero/xpcom/http.js @@ -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; + } } } } diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 80b5c540c7..c98f3ca0f3 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -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