Merge branch '3.0'
Conflicts: chrome/content/zotero/locale/csl chrome/content/zotero/xpcom/server_connector.js chrome/content/zotero/xpcom/storage.js
This commit is contained in:
commit
c2e116a49a
11 changed files with 68 additions and 32 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 671108216acf9995f96571588b52ea66e324aabf
|
Subproject commit 36d26a584ac869f2dfbdd528f57141a3bbcf016f
|
|
@ -31,8 +31,9 @@
|
||||||
* @param {String|nsIURI} uri URI of page to manage cookies for (cookies for domains that are not
|
* @param {String|nsIURI} uri URI of page to manage cookies for (cookies for domains that are not
|
||||||
* subdomains of this URI are ignored)
|
* subdomains of this URI are ignored)
|
||||||
* @param {String} cookieData Cookies with which to initiate the sandbox
|
* @param {String} cookieData Cookies with which to initiate the sandbox
|
||||||
|
* @param {String} userAgent User agent to use for sandboxed requests
|
||||||
*/
|
*/
|
||||||
Zotero.CookieSandbox = function(browser, uri, cookieData) {
|
Zotero.CookieSandbox = function(browser, uri, cookieData, userAgent) {
|
||||||
this._observerService = Components.classes["@mozilla.org/observer-service;1"].
|
this._observerService = Components.classes["@mozilla.org/observer-service;1"].
|
||||||
getService(Components.interfaces.nsIObserverService);
|
getService(Components.interfaces.nsIObserverService);
|
||||||
|
|
||||||
|
@ -54,6 +55,8 @@ Zotero.CookieSandbox = function(browser, uri, cookieData) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(userAgent) this.userAgent = userAgent;
|
||||||
|
|
||||||
Zotero.CookieSandbox.Observer.register();
|
Zotero.CookieSandbox.Observer.register();
|
||||||
if(browser) {
|
if(browser) {
|
||||||
this.attachToBrowser(browser);
|
this.attachToBrowser(browser);
|
||||||
|
@ -206,6 +209,10 @@ Zotero.CookieSandbox.Observer = new function() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(trackedBy.userAgent) {
|
||||||
|
channel.setRequestHeader("User-Agent", trackedBy.userAgent, false);
|
||||||
|
}
|
||||||
|
|
||||||
// add cookies to be sent to this domain
|
// add cookies to be sent to this domain
|
||||||
channel.setRequestHeader("Cookie", trackedBy.cookieString, false);
|
channel.setRequestHeader("Cookie", trackedBy.cookieString, false);
|
||||||
Zotero.debug("CookieSandbox: Added cookies for request to "+channelURI, 5);
|
Zotero.debug("CookieSandbox: Added cookies for request to "+channelURI, 5);
|
||||||
|
|
|
@ -2167,7 +2167,7 @@ Zotero.Integration.Session.prototype.getCitationField = function(citation) {
|
||||||
|
|
||||||
// add itemData only if requested
|
// add itemData only if requested
|
||||||
if(this.data.prefs.storeReferences) {
|
if(this.data.prefs.storeReferences) {
|
||||||
serializeCitationItem.itemData = citationItem.item;
|
serializeCitationItem.itemData = Zotero.Cite.System.retrieveItem(citationItem.id);
|
||||||
addSchema = true;
|
addSchema = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2507,6 +2507,8 @@ Zotero.Integration.Session.prototype.deleteCitation = function(index) {
|
||||||
Zotero.Integration.Session.prototype.getBibliography = function() {
|
Zotero.Integration.Session.prototype.getBibliography = function() {
|
||||||
this.updateUncitedItems();
|
this.updateUncitedItems();
|
||||||
|
|
||||||
|
if(Zotero.Utilities.isEmpty(this.citationsByItemID)) return false;
|
||||||
|
|
||||||
// generate bibliography
|
// generate bibliography
|
||||||
var bib = this.style.makeBibliography();
|
var bib = this.style.makeBibliography();
|
||||||
|
|
||||||
|
|
|
@ -410,6 +410,12 @@ Zotero.Search.prototype.addCondition = function(condition, operator, value, requ
|
||||||
|
|
||||||
for each(var part in parts) {
|
for each(var part in parts) {
|
||||||
this.addCondition('blockStart');
|
this.addCondition('blockStart');
|
||||||
|
|
||||||
|
// If search string is 8 characters, see if this is a item key
|
||||||
|
if (operator == 'contains' && part.text.length == 8) {
|
||||||
|
this.addCondition('key', 'is', part.text, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (condition == 'quicksearch-titleCreatorYear') {
|
if (condition == 'quicksearch-titleCreatorYear') {
|
||||||
this.addCondition('title', operator, part.text, false);
|
this.addCondition('title', operator, part.text, false);
|
||||||
this.addCondition('year', operator, part.text, false);
|
this.addCondition('year', operator, part.text, false);
|
||||||
|
@ -2180,6 +2186,19 @@ Zotero.SearchConditions = new function(){
|
||||||
noLoad: true
|
noLoad: true
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
operators: {
|
||||||
|
is: true,
|
||||||
|
isNot: true,
|
||||||
|
beginsWith: true
|
||||||
|
},
|
||||||
|
table: 'items',
|
||||||
|
field: 'key',
|
||||||
|
special: true,
|
||||||
|
noLoad: true
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'annotation',
|
name: 'annotation',
|
||||||
operators: {
|
operators: {
|
||||||
|
|
|
@ -383,9 +383,12 @@ Zotero.Server.DataListener.prototype._processEndpoint = function(method, postDat
|
||||||
|
|
||||||
// pass to endpoint
|
// pass to endpoint
|
||||||
if((endpoint.init.length ? endpoint.init.length : endpoint.init.arity) === 3) {
|
if((endpoint.init.length ? endpoint.init.length : endpoint.init.arity) === 3) {
|
||||||
|
const uaRe = /[\r\n]User-Agent: +([^\r\n]+)/i;
|
||||||
|
var m = uaRe.exec(this.header);
|
||||||
var url = {
|
var url = {
|
||||||
"pathname":this.pathname,
|
"pathname":this.pathname,
|
||||||
"query":this.query ? Zotero.Server.decodeQueryString(this.query.substr(1)) : {}
|
"query":this.query ? Zotero.Server.decodeQueryString(this.query.substr(1)) : {},
|
||||||
|
"userAgent":m && m[1]
|
||||||
};
|
};
|
||||||
|
|
||||||
endpoint.init(url, decodedData, sendResponseCallback);
|
endpoint.init(url, decodedData, sendResponseCallback);
|
||||||
|
|
14
chrome/content/zotero/xpcom/server_connector.js
Executable file → Normal file
14
chrome/content/zotero/xpcom/server_connector.js
Executable file → Normal file
|
@ -129,7 +129,7 @@ Zotero.Server.Connector.Detect.prototype = {
|
||||||
* @param {Object} data POST data or GET query string
|
* @param {Object} data POST data or GET query string
|
||||||
* @param {Function} sendResponseCallback function to send HTTP response
|
* @param {Function} sendResponseCallback function to send HTTP response
|
||||||
*/
|
*/
|
||||||
"init":function(data, sendResponseCallback) {
|
"init":function(url, data, sendResponseCallback) {
|
||||||
this.sendResponse = sendResponseCallback;
|
this.sendResponse = sendResponseCallback;
|
||||||
this._parsedPostData = data;
|
this._parsedPostData = data;
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ Zotero.Server.Connector.Detect.prototype = {
|
||||||
var pageShowCalled = false;
|
var pageShowCalled = false;
|
||||||
var me = this;
|
var me = this;
|
||||||
this._translate.setCookieSandbox(new Zotero.CookieSandbox(this._browser,
|
this._translate.setCookieSandbox(new Zotero.CookieSandbox(this._browser,
|
||||||
this._parsedPostData["uri"], this._parsedPostData["cookie"]));
|
this._parsedPostData["uri"], this._parsedPostData["cookie"], url.userAgent));
|
||||||
this._browser.addEventListener("DOMContentLoaded", function() {
|
this._browser.addEventListener("DOMContentLoaded", function() {
|
||||||
try {
|
try {
|
||||||
if(me._browser.contentDocument.location.href == "about:blank") return;
|
if(me._browser.contentDocument.location.href == "about:blank") return;
|
||||||
|
@ -322,7 +322,7 @@ Zotero.Server.Connector.SaveItem.prototype = {
|
||||||
* @param {Object} data POST data or GET query string
|
* @param {Object} data POST data or GET query string
|
||||||
* @param {Function} sendResponseCallback function to send HTTP response
|
* @param {Function} sendResponseCallback function to send HTTP response
|
||||||
*/
|
*/
|
||||||
"init":function(data, sendResponseCallback) {
|
"init":function(url, data, sendResponseCallback) {
|
||||||
// figure out where to save
|
// figure out where to save
|
||||||
var libraryID = null;
|
var libraryID = null;
|
||||||
var collectionID = null;
|
var collectionID = null;
|
||||||
|
@ -332,8 +332,8 @@ Zotero.Server.Connector.SaveItem.prototype = {
|
||||||
var collection = zp.getSelectedCollection();
|
var collection = zp.getSelectedCollection();
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
|
|
||||||
var cookieSandbox = data["uri"] && data["cookie"] ? new Zotero.CookieSandbox(null, data["uri"],
|
var cookieSandbox = data["uri"] ? new Zotero.CookieSandbox(null, data["uri"],
|
||||||
data["cookie"]) : null;
|
data["cookie"] || "", url.userAgent) : null;
|
||||||
for(var i=0; i<data.items.length; i++) {
|
for(var i=0; i<data.items.length; i++) {
|
||||||
Zotero.Server.Connector.AttachmentProgressManager.add(data.items[i].attachments);
|
Zotero.Server.Connector.AttachmentProgressManager.add(data.items[i].attachments);
|
||||||
}
|
}
|
||||||
|
@ -383,12 +383,12 @@ Zotero.Server.Connector.SaveSnapshot.prototype = {
|
||||||
* @param {String} data POST data or GET query string
|
* @param {String} data POST data or GET query string
|
||||||
* @param {Function} sendResponseCallback function to send HTTP response
|
* @param {Function} sendResponseCallback function to send HTTP response
|
||||||
*/
|
*/
|
||||||
"init":function(data, sendResponseCallback) {
|
"init":function(url, data, sendResponseCallback) {
|
||||||
Zotero.Server.Connector.Data[data["url"]] = "<html>"+data["html"]+"</html>";
|
Zotero.Server.Connector.Data[data["url"]] = "<html>"+data["html"]+"</html>";
|
||||||
var browser = Zotero.Browser.createHiddenBrowser();
|
var browser = Zotero.Browser.createHiddenBrowser();
|
||||||
|
|
||||||
var pageShowCalled = false;
|
var pageShowCalled = false;
|
||||||
var cookieSandbox = new Zotero.CookieSandbox(browser, data["url"], data["cookie"]);
|
var cookieSandbox = new Zotero.CookieSandbox(browser, data["url"], data["cookie"], url.userAgent);
|
||||||
browser.addEventListener("pageshow", function() {
|
browser.addEventListener("pageshow", function() {
|
||||||
if(browser.contentDocument.location.href == "about:blank"
|
if(browser.contentDocument.location.href == "about:blank"
|
||||||
|| browser.contentDocument.readyState !== "complete") return;
|
|| browser.contentDocument.readyState !== "complete") return;
|
||||||
|
|
|
@ -1256,20 +1256,20 @@ Zotero.Sync.Server = new function () {
|
||||||
Zotero.Sync.Runner.setSyncStatus(Zotero.getString('sync.status.loggingIn'));
|
Zotero.Sync.Runner.setSyncStatus(Zotero.getString('sync.status.loggingIn'));
|
||||||
|
|
||||||
Zotero.HTTP.doPost(url, body, function (xmlhttp) {
|
Zotero.HTTP.doPost(url, body, function (xmlhttp) {
|
||||||
_checkResponse(xmlhttp);
|
_checkResponse(xmlhttp, true);
|
||||||
|
|
||||||
var response = xmlhttp.responseXML.childNodes[0];
|
var response = xmlhttp.responseXML.childNodes[0];
|
||||||
|
|
||||||
if (response.firstChild.tagName == 'error') {
|
if (response.firstChild.tagName == 'error') {
|
||||||
if (response.firstChild.getAttribute('code') == 'INVALID_LOGIN') {
|
if (response.firstChild.getAttribute('code') == 'INVALID_LOGIN') {
|
||||||
var e = new Zotero.Error(Zotero.getString('sync.error.invalidLogin'), "INVALID_SYNC_LOGIN");
|
var e = new Zotero.Error(Zotero.getString('sync.error.invalidLogin'), "INVALID_SYNC_LOGIN");
|
||||||
_error(e);
|
_error(e, true);
|
||||||
}
|
}
|
||||||
_error(response.firstChild.firstChild.nodeValue);
|
_error(response.firstChild.firstChild.nodeValue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_sessionID) {
|
if (_sessionID) {
|
||||||
_error("Session ID already set in Zotero.Sync.Server.login()")
|
_error("Session ID already set in Zotero.Sync.Server.login()", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// <response><sessionID>[abcdefg0-9]{32}</sessionID></response>
|
// <response><sessionID>[abcdefg0-9]{32}</sessionID></response>
|
||||||
|
@ -1278,7 +1278,7 @@ Zotero.Sync.Server = new function () {
|
||||||
var re = /^[abcdefg0-9]{32}$/;
|
var re = /^[abcdefg0-9]{32}$/;
|
||||||
if (!re.test(_sessionID)) {
|
if (!re.test(_sessionID)) {
|
||||||
_sessionID = null;
|
_sessionID = null;
|
||||||
_error('Invalid session ID received from server');
|
_error('Invalid session ID received from server', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1352,7 +1352,7 @@ Zotero.Sync.Server = new function () {
|
||||||
Zotero.HTTP.doPost(url, body, function (xmlhttp) {
|
Zotero.HTTP.doPost(url, body, function (xmlhttp) {
|
||||||
Zotero.debug(xmlhttp.responseText);
|
Zotero.debug(xmlhttp.responseText);
|
||||||
|
|
||||||
_checkResponse(xmlhttp);
|
_checkResponse(xmlhttp, !restart);
|
||||||
|
|
||||||
if (_invalidSession(xmlhttp)) {
|
if (_invalidSession(xmlhttp)) {
|
||||||
Zotero.debug("Invalid session ID -- logging in");
|
Zotero.debug("Invalid session ID -- logging in");
|
||||||
|
@ -1772,13 +1772,10 @@ Zotero.Sync.Server = new function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function _checkResponse(xmlhttp) {
|
function _checkResponse(xmlhttp, noReloadOnFailure) {
|
||||||
if (!xmlhttp.responseText) {
|
if (!xmlhttp.responseText) {
|
||||||
// Check SSL cert
|
|
||||||
var channel = xmlhttp.channel;
|
var channel = xmlhttp.channel;
|
||||||
if (!channel instanceof Ci.nsIChannel) {
|
// Check SSL cert
|
||||||
_error('No HTTPS channel available');
|
|
||||||
}
|
|
||||||
var secInfo = channel.securityInfo;
|
var secInfo = channel.securityInfo;
|
||||||
if (secInfo instanceof Ci.nsITransportSecurityInfo) {
|
if (secInfo instanceof Ci.nsITransportSecurityInfo) {
|
||||||
secInfo.QueryInterface(Ci.nsITransportSecurityInfo);
|
secInfo.QueryInterface(Ci.nsITransportSecurityInfo);
|
||||||
|
@ -1794,14 +1791,19 @@ Zotero.Sync.Server = new function () {
|
||||||
Zotero.debug(e);
|
Zotero.debug(e);
|
||||||
}
|
}
|
||||||
// TODO: localize
|
// TODO: localize
|
||||||
_error("SSL certificate error connecting to " + host + "\n\nSee http://zotero.org/support/kb/ssl_certificate_error for more information.");
|
_error("SSL certificate error connecting to " + host
|
||||||
|
+ "\n\nSee http://zotero.org/support/kb/ssl_certificate_error for more information.",
|
||||||
|
false, noReloadOnFailure);
|
||||||
}
|
}
|
||||||
else if ((secInfo.securityState & Ci.nsIWebProgressListener.STATE_IS_BROKEN) == Ci.nsIWebProgressListener.STATE_IS_BROKEN) {
|
else if ((secInfo.securityState & Ci.nsIWebProgressListener.STATE_IS_BROKEN) == Ci.nsIWebProgressListener.STATE_IS_BROKEN) {
|
||||||
_error("SSL connection error");
|
_error("SSL connection error", false, noReloadOnFailure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: localize
|
// TODO: localize
|
||||||
_error('Empty response from server. Please try again in a few minutes.');
|
if (xmlhttp.status === 0) {
|
||||||
|
_error('Error connecting to server. Check your Internet connection.', false, noReloadOnFailure);
|
||||||
|
}
|
||||||
|
_error('Empty response from server. Please try again in a few minutes.', false, noReloadOnFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xmlhttp.responseXML || !xmlhttp.responseXML.childNodes[0] ||
|
if (!xmlhttp.responseXML || !xmlhttp.responseXML.childNodes[0] ||
|
||||||
|
@ -1809,7 +1811,7 @@ Zotero.Sync.Server = new function () {
|
||||||
!xmlhttp.responseXML.childNodes[0].firstChild) {
|
!xmlhttp.responseXML.childNodes[0].firstChild) {
|
||||||
Zotero.debug(xmlhttp.responseText);
|
Zotero.debug(xmlhttp.responseText);
|
||||||
// TODO: localize
|
// TODO: localize
|
||||||
_error('Invalid response from server. Please try again in a few minutes.', xmlhttp.responseText);
|
_error('Invalid response from server. Please try again in a few minutes.', xmlhttp.responseText, noReloadOnFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
var firstChild = xmlhttp.responseXML.firstChild.firstChild;
|
var firstChild = xmlhttp.responseXML.firstChild.firstChild;
|
||||||
|
@ -1828,7 +1830,7 @@ Zotero.Sync.Server = new function () {
|
||||||
else {
|
else {
|
||||||
var timeStr = time.toLocaleString();
|
var timeStr = time.toLocaleString();
|
||||||
}
|
}
|
||||||
_error("Auto-syncing disabled until " + timeStr);
|
_error("Auto-syncing disabled until " + timeStr, false, noReloadOnFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstChild.localName == 'error') {
|
if (firstChild.localName == 'error') {
|
||||||
|
@ -2244,7 +2246,7 @@ Zotero.Sync.Server = new function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function _error(e, extraInfo) {
|
function _error(e, extraInfo, skipReload) {
|
||||||
if (e.name && e.name == 'ZOTERO_ERROR') {
|
if (e.name && e.name == 'ZOTERO_ERROR') {
|
||||||
switch (e.error) {
|
switch (e.error) {
|
||||||
case Zotero.Error.ERROR_MISSING_OBJECT:
|
case Zotero.Error.ERROR_MISSING_OBJECT:
|
||||||
|
@ -2337,7 +2339,9 @@ Zotero.Sync.Server = new function () {
|
||||||
|
|
||||||
_syncInProgress = false;
|
_syncInProgress = false;
|
||||||
Zotero.DB.rollbackAllTransactions();
|
Zotero.DB.rollbackAllTransactions();
|
||||||
Zotero.reloadDataObjects();
|
if (!skipReload) {
|
||||||
|
Zotero.reloadDataObjects();
|
||||||
|
}
|
||||||
Zotero.Sync.EventListener.resetIgnored();
|
Zotero.Sync.EventListener.resetIgnored();
|
||||||
|
|
||||||
_callbacks.onError(e);
|
_callbacks.onError(e);
|
||||||
|
|
|
@ -1376,7 +1376,7 @@ Zotero.Translate.Base.prototype = {
|
||||||
"for(var key in this) {"+
|
"for(var key in this) {"+
|
||||||
"if("+createArrays+".indexOf(key) !== -1) {"+
|
"if("+createArrays+".indexOf(key) !== -1) {"+
|
||||||
"for each(var item in this[key]) {"+
|
"for each(var item in this[key]) {"+
|
||||||
"for(var key2 in item[key2]) {"+
|
"for(var key2 in item) {"+
|
||||||
"if(typeof item[key2] === 'xml') {"+
|
"if(typeof item[key2] === 'xml') {"+
|
||||||
"item[key2] = item[key2].toString();"+
|
"item[key2] = item[key2].toString();"+
|
||||||
"}"+
|
"}"+
|
||||||
|
|
|
@ -553,6 +553,7 @@ fulltext.indexState.partial = Partial
|
||||||
|
|
||||||
exportOptions.exportNotes = Export Notes
|
exportOptions.exportNotes = Export Notes
|
||||||
exportOptions.exportFileData = Export Files
|
exportOptions.exportFileData = Export Files
|
||||||
|
exportOptions.useJournalAbbreviation = Use Journal Abbreviation
|
||||||
charset.UTF8withoutBOM = Unicode (UTF-8 without BOM)
|
charset.UTF8withoutBOM = Unicode (UTF-8 without BOM)
|
||||||
charset.autoDetect = (auto detect)
|
charset.autoDetect = (auto detect)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#zotero-tb-item-from-page, #zotero-tb-snapshot-from-page, #zotero-tb-link-from-page,
|
#zotero-tb-item-from-page, #zotero-tb-snapshot-from-page, #zotero-tb-link-from-page,
|
||||||
#zotero-tb-fullscreen, #zotero-fullscreen-close-separator {
|
#zotero-tb-fullscreen, #zotero-fullscreen-close-separator, #zotero-close-button {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
|
@ -1 +1 @@
|
||||||
Subproject commit 521c95701073a239b27e717c99dfb384b481df58
|
Subproject commit af463b24e40f0b426a40b55cf5f0d74dcab0d5b0
|
Loading…
Reference in a new issue