From 4aa81bd39f43d0c3e3056f3209c870ea3cb1d31a Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Fri, 17 Feb 2012 12:15:54 -0500 Subject: [PATCH 1/2] Fix option to force charset --- chrome/content/zotero/xpcom/http.js | 47 ++++++++++++----------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/chrome/content/zotero/xpcom/http.js b/chrome/content/zotero/xpcom/http.js index 67e7cccfb0..3635bcb603 100644 --- a/chrome/content/zotero/xpcom/http.js +++ b/chrome/content/zotero/xpcom/http.js @@ -43,6 +43,11 @@ Zotero.HTTP = new function() { var channel = xmlhttp.channel; channel.QueryInterface(Components.interfaces.nsIHttpChannelInternal); channel.forceAllowThirdPartyCookie = true; + + // Set charset + if (responseCharset) { + channel.contentCharset = responseCharset; + } // Don't cache GET requests xmlhttp.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE; @@ -94,34 +99,20 @@ Zotero.HTTP = new function() { return false; } - // Workaround for "Accept third-party cookies" being off in Firefox 3.0.1 - // https://www.zotero.org/trac/ticket/1070 - if (Zotero.isFx30) { - const Cc = Components.classes; - const Ci = Components.interfaces; - var ds = Cc["@mozilla.org/webshell;1"]. - createInstance(Components.interfaces.nsIDocShellTreeItem). - QueryInterface(Ci.nsIInterfaceRequestor); - ds.itemType = Ci.nsIDocShellTreeItem.typeContent; - var xmlhttp = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]. - createInstance(Ci.nsIXMLHttpRequest); - xmlhttp.mozBackgroundRequest = true; - xmlhttp.open("POST", url, true); - xmlhttp.channel.loadGroup = ds.getInterface(Ci.nsILoadGroup); - xmlhttp.channel.loadFlags |= Ci.nsIChannel.LOAD_DOCUMENT_URI; - } - else { - var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] - .createInstance(); - // Prevent certificate/authentication dialogs from popping up - xmlhttp.mozBackgroundRequest = true; - xmlhttp.open('POST', url, true); - // Send cookie even if "Allow third-party cookies" is disabled (>=Fx3.6 only) - if (!Zotero.isFx35) { - var channel = xmlhttp.channel; - channel.QueryInterface(Components.interfaces.nsIHttpChannelInternal); - channel.forceAllowThirdPartyCookie = true; - } + var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] + .createInstance(); + // Prevent certificate/authentication dialogs from popping up + xmlhttp.mozBackgroundRequest = true; + xmlhttp.open('POST', url, true); + + // Send cookie even if "Allow third-party cookies" is disabled (>=Fx3.6 only) + var channel = xmlhttp.channel; + channel.QueryInterface(Components.interfaces.nsIHttpChannelInternal); + channel.forceAllowThirdPartyCookie = true; + + // Set charset + if (responseCharset) { + channel.contentCharset = responseCharset; } if (headers) { From 88edc08e78d703151405d43ac181b16d62d54237 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Fri, 17 Feb 2012 14:43:48 -0500 Subject: [PATCH 2/2] Expose XMLSerializer to translators --- .../zotero/xpcom/translation/translate_firefox.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/translation/translate_firefox.js b/chrome/content/zotero/xpcom/translation/translate_firefox.js index 392238ba88..26a8bfc1e6 100644 --- a/chrome/content/zotero/xpcom/translation/translate_firefox.js +++ b/chrome/content/zotero/xpcom/translation/translate_firefox.js @@ -75,9 +75,16 @@ Zotero.Translate.SandboxManager = function(sandboxLocation) { } else { this.parseFromString = function(str, contentType) _DOMParser.parseFromString(str, contentType); } - } + }; this.sandbox.DOMParser.__exposedProps__ = {"prototype":"r"}; this.sandbox.DOMParser.prototype = {}; + this.sandbox.XMLSerializer = function() { + var s = Components.classes["@mozilla.org/xmlextras/xmlserializer;1"] + .createInstance(Components.interfaces.nsIDOMSerializer); + this.serializeToString = function(doc) { + return s.serializeToString(doc.__wrappedDOMObject ? doc.__wrappedDOMObject : doc); + }; + }; } /**