diff --git a/chrome/content/zotero-platform/mac/overlay.css b/chrome/content/zotero-platform/mac/overlay.css index 495c128296..e1cd1e9801 100644 --- a/chrome/content/zotero-platform/mac/overlay.css +++ b/chrome/content/zotero-platform/mac/overlay.css @@ -328,4 +328,14 @@ treechildren::-moz-tree-image { #zotero-tb-actions-menu { list-style-image: url('chrome://zotero/skin/mac/cog.png'); +} + +#zotero-collectionmenu > .menuitem-iconic, #zotero-itemmenu > .menuitem-iconic, #zotero-collectionmenu > .menu-iconic, #zotero-itemmenu > .menu-iconic { + padding-top: 0px !important; + padding-bottom: 2px !important; + list-style-image: none !important; +} + +#zotero-collectionmenu > .menuitem-iconic > .menu-iconic-left, #zotero-itemmenu > .menuitem-iconic > .menu-iconic-left, #zotero-collectionmenu > .menu-iconic > .menu-iconic-left, #zotero-itemmenu > .menu-iconic > .menu-iconic-left { + display: none; } \ No newline at end of file diff --git a/chrome/content/zotero-platform/win/overlay.css b/chrome/content/zotero-platform/win/overlay.css index 05dea23438..1afdc6e0b5 100644 --- a/chrome/content/zotero-platform/win/overlay.css +++ b/chrome/content/zotero-platform/win/overlay.css @@ -22,7 +22,8 @@ } #zotero-tb-sync-error { - margin-right: 2px; + margin-right: 4px; + padding-top: 4px; } #zotero-tb-sync { diff --git a/chrome/content/zotero/bindings/styled-textbox.xml b/chrome/content/zotero/bindings/styled-textbox.xml index e227110847..47be7dc4c2 100644 --- a/chrome/content/zotero/bindings/styled-textbox.xml +++ b/chrome/content/zotero/bindings/styled-textbox.xml @@ -375,13 +375,17 @@ if (!SJOW.tinyMCE) { var exts = Zotero.getInstalledExtensions(function(exts) { for each(var ext in exts) { - if (ext.indexOf('NoScript') != -1) { - var warning = win.document.getElementById('noScriptWarning'); + if (ext.indexOf('NoScript') != -1 && ext.indexOf('disabled') == -1) { + var doc = win.document; + var div = doc.getElementById('tinymce'); + var warning = doc.createElement('div'); + warning.id = 'noScriptWarning'; var str = "The NoScript extension is preventing Zotero " + "from displaying notes. To use NoScript and Zotero together, " + "whitelist the 'file:' scheme in the NoScript preferences " + "and restart " + Zotero.appName + "."; warning.appendChild(document.createTextNode(str)); + div.appendChild(warning); break; } } diff --git a/chrome/content/zotero/bindings/tagselector.xml b/chrome/content/zotero/bindings/tagselector.xml index 413fa516e1..faca83397b 100644 --- a/chrome/content/zotero/bindings/tagselector.xml +++ b/chrome/content/zotero/bindings/tagselector.xml @@ -40,7 +40,8 @@ false null null - null + null + null @@ -206,7 +207,8 @@ } Zotero.debug('Refreshing tags selector'); - var empty = true; + var emptyColored = true; + var emptyRegular = true; var tagsToggleBox = this.id('tags-toggle'); var self = this; @@ -340,7 +342,7 @@ labels[i].className = 'zotero-clicky'; labels[i].setAttribute('inScope', true); labels[i].setAttribute('hidden', false); - empty = false; + emptyRegular = false; } else { labels[i].className = ''; @@ -360,21 +362,15 @@ } labels[i].setAttribute('hidden', false); - empty = false; + emptyRegular = false; } - // If tag isn't in scope and is still selected, deselect it - if (labels[i].getAttribute('hidden') == 'true' && self.selection[name]) { - labels[i].setAttribute('selected', false); - delete self.selection[name]; - var doCommand = true; - } - - - // Always show colored tags at top - if (colorData) { + // Always show colored tags at top, unless they + // don't match an active tag search + if (colorData && (!self._search || inSearch)) { labels[i].setAttribute('hidden', false); labels[i].setAttribute('hasColor', true); + emptyColored = false; } else { labels[i].removeAttribute('hasColor'); @@ -450,15 +446,16 @@ //end tag cloud code - self.updateNumSelected(); - self._empty = empty; + self._emptyColored = emptyColored; + self._emptyRegular = emptyRegular; + var empty = emptyColored && emptyRegular; self.id('tags-toggle').setAttribute('collapsed', empty); self.id('no-tags-box').setAttribute('collapsed', !empty); - if (doCommand) { - Zotero.debug('A selected tag went out of scope -- deselecting'); - self.doCommand(); + if (self.onRefresh) { + self.onRefresh(); + self.onRefresh = null; } }) .done(); @@ -563,14 +560,22 @@ me.setSearch(false, true); } me._dirty = true; - me.doCommand(); - // If no tags visible after a delete, deselect all - if ((event == 'remove' || event == 'delete') && - me._empty && me.getNumSelected()) { - Zotero.debug('No tags visible after delete -- deselecting all'); - me.clearAll(); - } + // This is a hack, but set this to run after the refresh, + // since _emptyRegular isn't set until then + me.onRefresh = function () { + // If no regular tags visible after a delete, deselect all. + // This is necessary so that a selected tag that's removed + // from its last item doesn't cause all regular tags to + // disappear without anything being visibly selected. + if ((event == 'remove' || event == 'delete') && + me._emptyRegular && me.getNumSelected()) { + Zotero.debug('No tags visible after delete -- deselecting all'); + me.clearAll(); + } + }; + + me.doCommand(); }, 0); this._notified = true; ]]> diff --git a/chrome/content/zotero/locateMenu.js b/chrome/content/zotero/locateMenu.js index 8b66cfeb4d..183fd8c3b5 100644 --- a/chrome/content/zotero/locateMenu.js +++ b/chrome/content/zotero/locateMenu.js @@ -93,8 +93,9 @@ var Zotero_LocateMenu = new function() { /** * Clear the bottom part of the context menu and add locate options * @param {menupopup} menu The menu to add context menu items to + * @param {Boolean} showIcons Whether menu items should have associated icons */ - this.buildContextMenu = function(menu) { + this.buildContextMenu = function(menu, showIcons) { // get selected items var selectedItems = _getSelectedItems(); @@ -102,7 +103,7 @@ var Zotero_LocateMenu = new function() { if(!selectedItems.length || selectedItems.length > 20) return; // add view options - _addViewOptions(menu, selectedItems); + _addViewOptions(menu, selectedItems, showIcons); /*// look for locate engines var availableEngines = _getAvailableLocateEngines(selectedItems); @@ -125,7 +126,7 @@ var Zotero_LocateMenu = new function() { null, Zotero.getString("locate."+optionName+".tooltip")); if(showIcons) { menuitem.setAttribute("class", "menuitem-iconic"); - menuitem.setAttribute("image", optionObject.icon); + menuitem.style.listStyleImage = "url('"+optionObject.icon+"')"; } menuitem.setAttribute("zotero-locate", "true"); diff --git a/chrome/content/zotero/lookup.js b/chrome/content/zotero/lookup.js index 2ef6d9e6f3..b7f10084c1 100644 --- a/chrome/content/zotero/lookup.js +++ b/chrome/content/zotero/lookup.js @@ -76,9 +76,9 @@ const Zotero_Lookup = new function () { //finally try for PMID if(!items.length) { - // PMID; right now, PMIDs are 8 digits, so it doesn't seem like we will need to - // discriminate for a fairly long time - var PMID_RE = /(?:\D|^)(\d{8})(?!\d)/g; + // PMID; right now, the longest PMIDs are 8 digits, so it doesn't + // seem like we will need to discriminate for a fairly long time + var PMID_RE = /(?:\D|^)(\d{1,9})(?!\d)/g; var pmid; while((pmid = PMID_RE.exec(identifier)) && foundIDs.indexOf(pmid) == -1) { items.push({itemType:"journalArticle", contextObject:"rft_id=info:pmid/"+pmid[1]}); diff --git a/chrome/content/zotero/tinymce/integration.html b/chrome/content/zotero/tinymce/integration.html index 9d72e91c7d..39bd5625a7 100755 --- a/chrome/content/zotero/tinymce/integration.html +++ b/chrome/content/zotero/tinymce/integration.html @@ -51,6 +51,6 @@ html, body { -
+
diff --git a/chrome/content/zotero/tinymce/note.html b/chrome/content/zotero/tinymce/note.html index 1931359d70..93142d0f4e 100644 --- a/chrome/content/zotero/tinymce/note.html +++ b/chrome/content/zotero/tinymce/note.html @@ -91,6 +91,6 @@ table.mceLayout { -
+
diff --git a/chrome/content/zotero/tinymce/noteview.html b/chrome/content/zotero/tinymce/noteview.html index 9b417bfd41..6a6653a2cc 100644 --- a/chrome/content/zotero/tinymce/noteview.html +++ b/chrome/content/zotero/tinymce/noteview.html @@ -68,6 +68,6 @@ table.mceLayout > tbody > tr.mceLast { -
+
diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js index c0deb002c3..713deee9eb 100644 --- a/chrome/content/zotero/tools/testTranslators/translatorTester.js +++ b/chrome/content/zotero/tools/testTranslators/translatorTester.js @@ -51,14 +51,19 @@ Zotero_TranslatorTesters = new function() { Zotero.Translators.getAllForType(TEST_TYPES[i], new function() { var type = TEST_TYPES[i]; return function(translators) { - for(var i=0; i + //

Foo

+ // + if (/^<[^>\n]+[^\/]>\n/.test(origText)) { + text = text.trim(); + } + var max = this.MAX_TITLE_LENGTH; var t = text.substring(0, max); diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index 57688d467f..7383d4572f 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -523,54 +523,34 @@ Zotero.File = new function(){ } if (e.name == 'NS_ERROR_FILE_ACCESS_DENIED' || e.name == 'NS_ERROR_FILE_IS_LOCKED' - // Shows up on some Windows systems - || e.name == 'NS_ERROR_FAILURE') { + // These show up on some Windows systems + || e.name == 'NS_ERROR_FAILURE' || e.name == 'NS_ERROR_FILE_NOT_FOUND') { Zotero.debug(e); str = str + " " + Zotero.getString('file.accessError.cannotBe') + " " + opWord + "."; var checkFileWindows = Zotero.getString('file.accessError.message.windows'); var checkFileOther = Zotero.getString('file.accessError.message.other'); - var msg = str + " " + var msg = str + "\n\n" + (Zotero.isWin ? checkFileWindows : checkFileOther) + "\n\n" + Zotero.getString('file.accessError.restart'); - if (operation == 'create') { - var e = new Zotero.Error( - msg, - 0, - { - dialogButtonText: Zotero.getString('file.accessError.showParentDir'), - dialogButtonCallback: function () { - try { - file.parent.QueryInterface(Components.interfaces.nsILocalFile).reveal(); - } - // Unsupported on some platforms - catch (e2) { - Zotero.debug(e2); - } + var e = new Zotero.Error( + msg, + 0, + { + dialogButtonText: Zotero.getString('file.accessError.showParentDir'), + dialogButtonCallback: function () { + try { + file.parent.QueryInterface(Components.interfaces.nsILocalFile); + file.parent.reveal(); + } + // Unsupported on some platforms + catch (e2) { + Zotero.launchFile(file.parent); } } - ); - } - else { - var e = new Zotero.Error( - msg, - 0, - { - dialogButtonText: Zotero.getString('locate.showFile.label'), - dialogButtonCallback: function () { - try { - file.QueryInterface(Components.interfaces.nsILocalFile); - file.reveal(); - } - // Unsupported on some platforms - catch (e2) { - Zotero.debug(e2); - } - } - } - ); - } + } + ); } throw (e); diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index 6803904ad5..8fea620240 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -1327,7 +1327,7 @@ Zotero.Integration.Fields.prototype.get = function get() { // If already getting fields, just return the promise if(this._deferreds) { this._deferreds.push(deferred); - return deferred; + return deferred.promise; } else { this._deferreds = [deferred]; } diff --git a/chrome/content/zotero/xpcom/server_connector.js b/chrome/content/zotero/xpcom/server_connector.js index 1e3a2cd23c..402426e7f9 100644 --- a/chrome/content/zotero/xpcom/server_connector.js +++ b/chrome/content/zotero/xpcom/server_connector.js @@ -624,8 +624,8 @@ Zotero.Server.Connector.IEHack.prototype = { "init":function(postData, sendResponseCallback) { sendResponseCallback(200, "text/html", ''+ - ''+ - ''+ + ''+ + ''+ ''); } } diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index b0e9d55c33..45d8ef3652 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -1607,18 +1607,18 @@ Zotero.Sync.Storage = new function () { // Do deletes outside of the enumerator to avoid an access error on Windows for each(var file in filesToDelete) { - if (file.isFile()) { - Zotero.debug("Deleting existing file " + file.leafName); - try { + try { + if (file.isFile()) { + Zotero.debug("Deleting existing file " + file.leafName); file.remove(false); } - catch (e) { - Zotero.File.checkFileAccessError(e, file, 'delete'); + else if (file.isDirectory()) { + Zotero.debug("Deleting existing directory " + file.leafName); + file.remove(true); } } - else if (file.isDirectory()) { - Zotero.debug("Deleting existing directory " + file.leafName); - file.remove(true); + catch (e) { + Zotero.File.checkFileAccessError(e, file, 'delete'); } } } diff --git a/chrome/content/zotero/xpcom/storage/queue.js b/chrome/content/zotero/xpcom/storage/queue.js index 5b49620266..1ef7cb01b1 100644 --- a/chrome/content/zotero/xpcom/storage/queue.js +++ b/chrome/content/zotero/xpcom/storage/queue.js @@ -413,7 +413,7 @@ Zotero.Sync.Storage.Queue.prototype.stop = function () { this._stopping = true; for each(var request in this._requests) { if (!request.isFinished()) { - request.stop(); + request.stop(true); } } diff --git a/chrome/content/zotero/xpcom/storage/request.js b/chrome/content/zotero/xpcom/storage/request.js index 44e091af84..b62532a86a 100644 --- a/chrome/content/zotero/xpcom/storage/request.js +++ b/chrome/content/zotero/xpcom/storage/request.js @@ -48,6 +48,7 @@ Zotero.Sync.Storage.Request = function (name, callbacks) { this._remaining = null; this._maxSize = null; this._finished = false; + this._forceFinish = false; this._changesMade = false; for (var func in callbacks) { @@ -308,7 +309,11 @@ Zotero.Sync.Storage.Request.prototype.onProgress = function (channel, progress, /** * Stop the request's underlying network request, if there is one */ -Zotero.Sync.Storage.Request.prototype.stop = function () { +Zotero.Sync.Storage.Request.prototype.stop = function (force) { + if (force) { + this._forceFinish = true; + } + if (this.channel) { this._stopping = true; @@ -330,6 +335,15 @@ Zotero.Sync.Storage.Request.prototype.stop = function () { * Mark request as finished and notify queue that it's done */ Zotero.Sync.Storage.Request.prototype._finish = function () { + // If an error occurred, we wait to finish the request, since doing + // so might end the queue before the error flag has been set on the queue. + // When the queue's error handler stops the queue, it stops the request + // with stop(true) to force the finish to occur, allowing the queue's + // promise to be rejected with the error. + if (!this._forceFinish && this._deferred.promise.isRejected()) { + return; + } + Zotero.debug("Finishing " + this.queue.name + " request '" + this.name + "'"); this._finished = true; var active = this._running; diff --git a/chrome/content/zotero/xpcom/storage/webdav.js b/chrome/content/zotero/xpcom/storage/webdav.js index 5f794d2f50..ee0c5578c6 100644 --- a/chrome/content/zotero/xpcom/storage/webdav.js +++ b/chrome/content/zotero/xpcom/storage/webdav.js @@ -271,6 +271,8 @@ Zotero.Sync.Storage.WebDAV = (function () { request.onProgress(a, b, c); }, onStop: function (httpRequest, status, response, data) { + data.request.setChannel(false); + deferred.resolve( Q.fcall(function () { return onUploadComplete(httpRequest, status, response, data); @@ -880,6 +882,8 @@ Zotero.Sync.Storage.WebDAV = (function () { request.onProgress(a, b, c) }, onStop: function (request, status, response, data) { + data.request.setChannel(false); + if (status == 404) { var msg = "Remote ZIP file not found for item " + item.key; Zotero.debug(msg, 2); diff --git a/chrome/content/zotero/xpcom/storage/zfs.js b/chrome/content/zotero/xpcom/storage/zfs.js index 5462a0012b..cdad1f0307 100644 --- a/chrome/content/zotero/xpcom/storage/zfs.js +++ b/chrome/content/zotero/xpcom/storage/zfs.js @@ -463,6 +463,8 @@ Zotero.Sync.Storage.ZFS = (function () { request.onProgress(a, b, c); }, onStop: function (httpRequest, status, response, data) { + data.request.setChannel(false); + deferred.resolve( onUploadComplete(httpRequest, status, response, data) ); @@ -803,6 +805,8 @@ Zotero.Sync.Storage.ZFS = (function () { request.onProgress(a, b, c) }, onStop: function (request, status, response, data) { + data.request.setChannel(false); + if (status != 200) { var msg = "Unexpected status code " + status + " for request " + data.request.name diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js index 29a95d0be0..341d5b7d17 100644 --- a/chrome/content/zotero/xpcom/sync.js +++ b/chrome/content/zotero/xpcom/sync.js @@ -1228,9 +1228,18 @@ Zotero.Sync.Server = new function () { } catch (e) { Zotero.debug(e); - var msg = Zotero.getString('sync.error.loginManagerCorrupted1', Zotero.appName) + "\n\n" - + Zotero.getString('sync.error.loginManagerCorrupted2', [Zotero.appName, Zotero.appName]); - alert(msg); + if (Zotero.isStandalone) { + var msg = Zotero.getString('sync.error.loginManagerCorrupted1', Zotero.appName) + "\n\n" + + Zotero.getString('sync.error.loginManagerCorrupted2', [Zotero.appName, Zotero.appName]); + } + else { + var msg = Zotero.getString('sync.error.loginManagerInaccessible') + "\n\n" + + Zotero.getString('sync.error.checkMasterPassword', Zotero.appName) + "\n\n" + + Zotero.getString('sync.error.corruptedLoginManager', Zotero.appName); + } + var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); + ps.alert(null, Zotero.getString('general.error'), msg); return ''; } @@ -2688,7 +2697,7 @@ Zotero.Sync.Server.Data = new function() { var tagID = Zotero.DB.valueQuery(sql, [libraryID, key]); var sql = "SELECT COUNT(*) > 0 FROM itemTags WHERE tagID=?"; - if (Zotero.DB.valueQuery(sql, [tagID])) { + if (tagID && Zotero.DB.valueQuery(sql, [tagID])) { var sql = "UPDATE tags SET clientDateModified=CURRENT_TIMESTAMP " + "WHERE tagID=?"; Zotero.DB.query(sql, [tagID]); @@ -3746,7 +3755,8 @@ Zotero.Sync.Server.Data = new function() { else { msg += Zotero.getString('sync.conflict.recentVersionsKept'); } - msg += "\n\n" + Zotero.getString('sync.conflict.viewErrorConsole', (Zotero.isStandalone ? "" : " Firefox")); + msg += "\n\n" + Zotero.getString('sync.conflict.viewErrorConsole', + (Zotero.isStandalone ? "" : "Firefox")).replace(/\s+/, " "); return msg; } @@ -3786,8 +3796,9 @@ Zotero.Sync.Server.Data = new function() { function _generateCollectionItemMergeAlertMessage() { - var msg = Zotero.getString('sync.conflict.collectionItemMerge.alert') - + Zotero.getString('sync.conflict.viewErrorConsole', (Zotero.isStandalone ? "" : "Firefox ")); + var msg = Zotero.getString('sync.conflict.collectionItemMerge.alert') + "\n\n" + + Zotero.getString('sync.conflict.viewErrorConsole', + (Zotero.isStandalone ? "" : "Firefox")).replace(/\s+/, " "); return msg; } @@ -3821,8 +3832,9 @@ Zotero.Sync.Server.Data = new function() { function _generateTagItemMergeAlertMessage() { - var msg = Zotero.getString('sync.conflict.tagItemMerge.alert') - + Zotero.getString('sync.conflict.viewErrorConsole', (Zotero.isStandalone ? "" : "Firefox ")); + var msg = Zotero.getString('sync.conflict.tagItemMerge.alert') + "\n\n" + + Zotero.getString('sync.conflict.viewErrorConsole', + (Zotero.isStandalone ? "" : "Firefox")).replace(/\s+/, " "); return msg; } diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index ffde3fd48f..54edc41a79 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -630,14 +630,11 @@ Zotero.Translate.Sandbox = { } } - // Remap attachment (but not link) URLs - var properToProxy = translate.translator[0].properToProxy; - if(properToProxy && item.attachments) { - for(var i=0; i + // possible, because this approach preserves line endings in the HTML if(node === undefined) { var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"] .createInstance(Components.interfaces.nsIDOMParser); diff --git a/chrome/content/zotero/xpcom/utilities_translate.js b/chrome/content/zotero/xpcom/utilities_translate.js index a386b9e497..3975430aae 100644 --- a/chrome/content/zotero/xpcom/utilities_translate.js +++ b/chrome/content/zotero/xpcom/utilities_translate.js @@ -195,17 +195,18 @@ Zotero.Utilities.Translate.prototype.loadDocument = function(url, succeeded, fai * @ignore */ Zotero.Utilities.Translate.prototype.processDocuments = function(urls, processor, done, exception) { + var translate = this._translate; + if(typeof(urls) == "string") { - urls = [this._convertURL(urls)]; + urls = [translate.resolveURL(urls)]; } else { for(var i in urls) { - urls[i] = this._convertURL(urls[i]); + urls[i] = translate.resolveURL(urls[i]); } } // Unless the translator has proposed some way to handle an error, handle it // by throwing a "scraping error" message - var translate = this._translate; if(exception) { var myException = function(e) { var browserDeleted; @@ -300,7 +301,9 @@ Zotero.Utilities.Translate.prototype.processDocuments = function(urls, processor * @return {Boolean} True if the request was sent, or false if the browser is offline */ Zotero.Utilities.Translate.prototype.doGet = function(urls, processor, done, responseCharset) { - var callAgain = false; + var callAgain = false, + me = this, + translate = this._translate; if(typeof(urls) == "string") { var url = urls; @@ -309,11 +312,9 @@ Zotero.Utilities.Translate.prototype.doGet = function(urls, processor, done, res var url = urls.shift(); } - url = this._convertURL(url); + url = translate.resolveURL(url); - var me = this; - - this._translate.incrementAsyncProcesses("Zotero.Utilities.Translate#doGet"); + translate.incrementAsyncProcesses("Zotero.Utilities.Translate#doGet"); var xmlhttp = Zotero.HTTP.doGet(url, function(xmlhttp) { try { if(processor) { @@ -327,9 +328,9 @@ Zotero.Utilities.Translate.prototype.doGet = function(urls, processor, done, res done(); } } - me._translate.decrementAsyncProcesses("Zotero.Utilities.Translate#doGet"); + translate.decrementAsyncProcesses("Zotero.Utilities.Translate#doGet"); } catch(e) { - me._translate.complete(false, e); + translate.complete(false, e); } }, responseCharset, this._translate.cookieSandbox); } @@ -339,10 +340,10 @@ Zotero.Utilities.Translate.prototype.doGet = function(urls, processor, done, res * @ignore */ Zotero.Utilities.Translate.prototype.doPost = function(url, body, onDone, headers, responseCharset) { - url = this._convertURL(url); - var translate = this._translate; - this._translate.incrementAsyncProcesses("Zotero.Utilities.Translate#doPost"); + url = translate.resolveURL(url); + + translate.incrementAsyncProcesses("Zotero.Utilities.Translate#doPost"); var xmlhttp = Zotero.HTTP.doPost(url, body, function(xmlhttp) { try { onDone(xmlhttp.responseText, xmlhttp); @@ -353,55 +354,6 @@ Zotero.Utilities.Translate.prototype.doPost = function(url, body, onDone, header }, headers, responseCharset, translate.cookieSandbox ? translate.cookieSandbox : undefined); } -/** - * Translate a URL to a form that goes through the appropriate proxy, or convert a relative URL to - * an absolute one - * - * @param {String} url - * @type String - * @private - */ -Zotero.Utilities.Translate.prototype._convertURL = function(url) { - const hostPortRe = /^((?:http|https|ftp):)\/\/([^\/]+)/i; - // resolve local URL - var resolved = ""; - - // convert proxy to proper if applicable - if(hostPortRe.test(url)) { - if(this._translate.translator && this._translate.translator[0] - && this._translate.translator[0].properToProxy) { - resolved = this._translate.translator[0].properToProxy(url); - } else { - resolved = url; - } - } else if(Zotero.isFx) { - resolved = Components.classes["@mozilla.org/network/io-service;1"]. - getService(Components.interfaces.nsIIOService). - newURI(this._translate.location, "", null).resolve(url); - } else if(Zotero.isNode) { - resolved = require('url').resolve(this._translate.location, url); - } else { - var a = document.createElement('a'); - a.href = url; - resolved = a.href; - } - - /*var m = hostPortRe.exec(resolved); - if(!m) { - throw new Error("Invalid URL supplied for HTTP request: "+url); - } else if(this._translate.document && this._translate.document.location) { - var loc = this._translate.document.location; - if(this._translate._currentState !== "translate" && loc - && (m[1].toLowerCase() !== loc.protocol.toLowerCase() - || m[2].toLowerCase() !== loc.host.toLowerCase())) { - throw new Error("Attempt to access "+m[1]+"//"+m[2]+" from "+loc.protocol+"//"+loc.host - +" blocked: Cross-site requests are only allowed during translation"); - } - }*/ - - return resolved; -} - Zotero.Utilities.Translate.prototype.__exposedProps__ = {"HTTP":"r"}; for(var j in Zotero.Utilities.Translate.prototype) { if(typeof Zotero.Utilities.Translate.prototype[j] === "function" && j[0] !== "_" && j != "Translate") { diff --git a/chrome/content/zotero/xpcom/xregexp/addons/unicode/unicode-zotero.js b/chrome/content/zotero/xpcom/xregexp/addons/unicode/unicode-zotero.js index 03c3cca66e..1fbe2043cb 100644 --- a/chrome/content/zotero/xpcom/xregexp/addons/unicode/unicode-zotero.js +++ b/chrome/content/zotero/xpcom/xregexp/addons/unicode/unicode-zotero.js @@ -38,8 +38,7 @@ name: 'Term', alias: 'Terminal_Punctuation', bmp: '\x21\x2C\x2E\x3A-\x3B\x3F\u037E\u0387\u0589\u05C3\u060C\u061B\u061F\u06D4\u0700-\u070A\u070C\u07F8-\u07F9\u0964-\u0965\u0E5A-\u0E5B\u0F08\u0F0D-\u0F12\u104A-\u104B\u1361-\u1368\u166D-\u166E\u16EB-\u16ED\u17D4-\u17D6\u17DA\u1802-\u1805\u1808-\u1809\u1944-\u1945\u1B5A-\u1B5B\u1B5D-\u1B5F\u1C3B-\u1C3F\u1C7E-\u1C7F\u203C-\u203D\u2047-\u2049\u2E2E\u3001-\u3002\uA60D-\uA60F\uA876-\uA877\uA8CE-\uA8CF\uA92F\uAA5D-\uAA5F\uFE50-\uFE52\uFE54-\uFE57\uFF01\uFF0C\uFF0E\uFF1A-\uFF1B\uFF1F\uFF61\uFF64\u1039F\u103D0\u1091F\u12470-\u12473' - }, - + } ]); }(XRegExp)); diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 38cd7ed6e7..24db4e530d 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1137,6 +1137,58 @@ Components.utils.import("resource://gre/modules/Services.jsm"); } + /** + * Launch a file, the best way we can + */ + this.launchFile = function (file) { + try { + file.launch(); + } + catch (e) { + Zotero.debug("launch() not supported -- trying fallback executable"); + + try { + if (Zotero.isWin) { + var pref = "fallbackLauncher.windows"; + } + else { + var pref = "fallbackLauncher.unix"; + } + var path = Zotero.Prefs.get(pref); + + var exec = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + exec.initWithPath(path); + if (!exec.exists()) { + throw (path + " does not exist"); + } + + var proc = Components.classes["@mozilla.org/process/util;1"] + .createInstance(Components.interfaces.nsIProcess); + proc.init(exec); + + var args = [file.path]; + proc.runw(true, args, args.length); + } + catch (e) { + Zotero.debug(e); + Zotero.debug("Launching via executable failed -- passing to loadUrl()"); + + // If nsILocalFile.launch() isn't available and the fallback + // executable doesn't exist, we just let the Firefox external + // helper app window handle it + var nsIFPH = Components.classes["@mozilla.org/network/protocol;1?name=file"] + .getService(Components.interfaces.nsIFileProtocolHandler); + var uri = nsIFPH.newFileURI(file); + + var nsIEPS = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]. + getService(Components.interfaces.nsIExternalProtocolService); + nsIEPS.loadUrl(uri); + } + } + } + + /* * Debug logging function * @@ -1845,6 +1897,7 @@ Components.utils.import("resource://gre/modules/Services.jsm"); Zotero.Items.reloadAll(); } + /** * Brings Zotero Standalone to the foreground */ diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index b4e0417b8d..d141270644 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -2400,7 +2400,7 @@ var ZoteroPane = new function() } // add locate menu options - Zotero_LocateMenu.buildContextMenu(menu); + Zotero_LocateMenu.buildContextMenu(menu, true); } @@ -3464,7 +3464,7 @@ var ZoteroPane = new function() this.loadURI(url, event); } else { - this.launchFile(file); + Zotero.launchFile(file); } } else { @@ -3507,54 +3507,11 @@ var ZoteroPane = new function() /** - * Launch a file, the best way we can + * @deprecated */ this.launchFile = function (file) { - try { - file.launch(); - } - catch (e) { - Zotero.debug("launch() not supported -- trying fallback executable"); - - try { - if (Zotero.isWin) { - var pref = "fallbackLauncher.windows"; - } - else { - var pref = "fallbackLauncher.unix"; - } - var path = Zotero.Prefs.get(pref); - - var exec = Components.classes["@mozilla.org/file/local;1"] - .createInstance(Components.interfaces.nsILocalFile); - exec.initWithPath(path); - if (!exec.exists()) { - throw (path + " does not exist"); - } - - var proc = Components.classes["@mozilla.org/process/util;1"] - .createInstance(Components.interfaces.nsIProcess); - proc.init(exec); - - var args = [file.path]; - proc.runw(true, args, args.length); - } - catch (e) { - Zotero.debug(e); - Zotero.debug("Launching via executable failed -- passing to loadUrl()"); - - // If nsILocalFile.launch() isn't available and the fallback - // executable doesn't exist, we just let the Firefox external - // helper app window handle it - var nsIFPH = Components.classes["@mozilla.org/network/protocol;1?name=file"] - .getService(Components.interfaces.nsIFileProtocolHandler); - var uri = nsIFPH.newFileURI(file); - - var nsIEPS = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]. - getService(Components.interfaces.nsIExternalProtocolService); - nsIEPS.loadUrl(uri); - } - } + Zotero.debug("ZoteroPane.launchFile() is deprecated -- use Zotero.launchFile()", 2); + Zotero.launchFile(file); } @@ -3626,7 +3583,7 @@ var ZoteroPane = new function() // On platforms that don't support nsILocalFile.reveal() (e.g. Linux), // launch the parent directory var parent = file.parent.QueryInterface(Components.interfaces.nsILocalFile); - this.launchFile(parent); + Zotero.launchFile(parent); } } else { diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul index ac26fe49f8..cb59bd136d 100644 --- a/chrome/content/zotero/zoteroPane.xul +++ b/chrome/content/zotero/zoteroPane.xul @@ -237,31 +237,31 @@ - - - + + + - - - - - + + + + + - - - - - + + + + + - + - - + + @@ -271,20 +271,20 @@ - - - - - + + + + + - - - + + + - - - - +