From f47b878f7b10712add6aa59d0a17afcea763583a Mon Sep 17 00:00:00 2001 From: adam3smith Date: Tue, 23 Apr 2013 13:26:41 -0600 Subject: [PATCH 1/4] add more item handler protocols to add by URI --- chrome/content/zotero/xpcom/attachments.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index 32e641012..9bf354050 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -212,9 +212,8 @@ Zotero.Attachments = new function(){ } // Throw error on invalid URLs - // - // TODO: allow other schemes - var urlRe = /^https?:\/\/[^\s]*$/; + var urlRe = /^((https?|evernote|onenote|brain|nv|mlo|kindle|x-devonthink-item|ftp):\/\/|logosres:)[^\s]*$/; + var matches = urlRe.exec(url); if (!matches) { if(callback) callback(false); From 4a4490923b49d98bff4f49f3c8d77ee8b3c7d54b Mon Sep 17 00:00:00 2001 From: adam3smith Date: Tue, 23 Apr 2013 14:21:43 -0600 Subject: [PATCH 2/4] add protocol description --- chrome/content/zotero/xpcom/attachments.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index 9bf354050..62658df51 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -211,7 +211,17 @@ Zotero.Attachments = new function(){ parentCollectionIDs = undefined; } - // Throw error on invalid URLs + /* Throw error on invalid URLs + We currently accept the following protocols: + PersonalBrain (brain://) + DevonThink (x-devonthink-item://) + Notational Velocity (nv://) + MyLife Organized (mlo://) + Evernote (evernote://) + OneNote (onenote://) + Kindle (kindle://) + Logos (logosres:) */ + var urlRe = /^((https?|evernote|onenote|brain|nv|mlo|kindle|x-devonthink-item|ftp):\/\/|logosres:)[^\s]*$/; var matches = urlRe.exec(url); From e901cc1bf39780870cab8b0b30e882d28e405249 Mon Sep 17 00:00:00 2001 From: adam3smith Date: Tue, 23 Apr 2013 18:20:45 -0600 Subject: [PATCH 3/4] add Zotero protocoll --- chrome/content/zotero/xpcom/attachments.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index 62658df51..5599f0b11 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -220,9 +220,10 @@ Zotero.Attachments = new function(){ Evernote (evernote://) OneNote (onenote://) Kindle (kindle://) - Logos (logosres:) */ + Logos (logosres:) + Zotero (zotero://) */ - var urlRe = /^((https?|evernote|onenote|brain|nv|mlo|kindle|x-devonthink-item|ftp):\/\/|logosres:)[^\s]*$/; + var urlRe = /^((https?|zotero|evernote|onenote|brain|nv|mlo|kindle|x-devonthink-item|ftp):\/\/|logosres:)[^\s]*$/; var matches = urlRe.exec(url); if (!matches) { From e68889af45b24896d9dd7845a045718be5efa1a5 Mon Sep 17 00:00:00 2001 From: adam3smith Date: Thu, 25 Apr 2013 16:08:59 -0600 Subject: [PATCH 4/4] put this into the right function --- chrome/content/zotero/xpcom/attachments.js | 35 +++++++++++----------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index 5599f0b11..f789e125b 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -211,20 +211,10 @@ Zotero.Attachments = new function(){ parentCollectionIDs = undefined; } - /* Throw error on invalid URLs - We currently accept the following protocols: - PersonalBrain (brain://) - DevonThink (x-devonthink-item://) - Notational Velocity (nv://) - MyLife Organized (mlo://) - Evernote (evernote://) - OneNote (onenote://) - Kindle (kindle://) - Logos (logosres:) - Zotero (zotero://) */ - - var urlRe = /^((https?|zotero|evernote|onenote|brain|nv|mlo|kindle|x-devonthink-item|ftp):\/\/|logosres:)[^\s]*$/; - + // Throw error on invalid URLs + // + // TODO: allow other schemes + var urlRe = /^https?:\/\/[^\s]*$/; var matches = urlRe.exec(url); if (!matches) { if(callback) callback(false); @@ -419,9 +409,20 @@ Zotero.Attachments = new function(){ */ function linkFromURL(url, sourceItemID, mimeType, title){ Zotero.debug('Linking attachment from URL'); - - // Throw error on invalid URLs - var urlRe = /^https?:\/\/[^\s]*$/; + + /* Throw error on invalid URLs + We currently accept the following protocols: + PersonalBrain (brain://) + DevonThink (x-devonthink-item://) + Notational Velocity (nv://) + MyLife Organized (mlo://) + Evernote (evernote://) + OneNote (onenote://) + Kindle (kindle://) + Logos (logosres:) + Zotero (zotero://) */ + + var urlRe = /^((https?|zotero|evernote|onenote|brain|nv|mlo|kindle|x-devonthink-item|ftp):\/\/|logosres:)[^\s]*$/; var matches = urlRe.exec(url); if (!matches) { throw ("Invalid URL '" + url + "' in Zotero.Attachments.linkFromURL()");