From 857c42c40b8d562a7b1ad79f7119437992525210 Mon Sep 17 00:00:00 2001 From: Dan Stillman <dstillman@zotero.org> Date: Mon, 6 Jan 2020 15:41:36 -0500 Subject: [PATCH] Allow additional characters in URL scheme for attachments/launchURL() https://forums.zotero.org/discussion/comment/345977/#Comment_345977 --- chrome/content/zotero/xpcom/attachments.js | 3 ++- chrome/content/zotero/xpcom/zotero.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index f985a47457..38ad57614b 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -606,7 +606,8 @@ Zotero.Attachments = new function(){ var title = options.title; var collections = options.collections; - var matches = url.match(/^([a-z]+):(\/\/)?.+/); + var schemeRE = /^([a-z][a-z0-9+.-]+):/; + var matches = url.match(schemeRE); if (!matches) { throw new Error(`Invalid URL '${url}'`); } diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index a24a3e06ac..a94f70dce0 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1032,7 +1032,8 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js"); } // Launch non-HTTP URLs else { - let matches = url.match(/^([a-z]+):/); + let schemeRE = /^([a-z][a-z0-9+.-]+):/; + let matches = url.match(schemeRE); if (!matches) { throw new Error(`Invalid URL '${url}'`); }