Skip to content
Snippets Groups Projects
Commit 56d349f9 authored by David Byers's avatar David Byers
Browse files

Merge branch '11-copy-original-link-doesn-t-work-for-barracuda-links' into 'master'

Resolve "Copy original link doesn't work for Barracuda links"

Closes #11

See merge request !12
parents 1ea428a6 3b9f5166
No related branches found
No related tags found
1 merge request!12Resolve "Copy original link doesn't work for Barracuda links"
Pipeline #38504 passed
{
"background": {
"scripts": [
"patterns.js",
"links.js",
"menu.js"
]
......@@ -16,6 +17,7 @@
],
"js": [
"mutation.js",
"patterns.js",
"links.js",
"popup.js",
"content.js"
......
......@@ -22,25 +22,6 @@
// Shared code
/**
* List of regexps that match safe links. The original URL must be
* collected in match group 1.
*/
const regexpList = [
'https?://[^.]+[.]safelinks[.]protection[.]outlook[.]com/[?]url=([^&]+)&.*',
'https?://linkprotect[.]cudasvc[.]com/url[?]a=([^&]+)&.*'
];
/**
* Concatenated regexp for all safe links types.
*/
const safelinksRegexp = new RegExp(
'(?:' + regexpList.map((string) => '(?:' + string + ')').join('|') + ')',
'gi'
);
/**
* The ID for the popup element that is added to the HTML document.
*/
......
......@@ -54,7 +54,7 @@ browser.menus.create({
title: browser.i18n.getMessage("copyLinkMenuTitle"),
contexts: ["link"],
visible: true,
targetUrlPatterns: ["*://*.safelinks.protection.outlook.com/*"],
targetUrlPatterns: computeSafelinksMatchPatterns()
});
browser.menus.onClicked.addListener((info, tab) => {
......
// Safe Links Cleaner
// Copyright 2021 David Byers <david.byers@liu.se>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// Shared code
const safelinksPatterns = [
{
host: '*.safelinks.protection.outlook.com',
path: '[?]url=([^&]+).*'
},
{
host: 'linkprotect.cudasvc.com',
path: 'url[?]a=([^&]+).*'
}
];
function computeSafelinksMatchPatterns() {
return safelinksPatterns.map(({host, path}) => '*://' + host + '/*');
}
function escapeHostname(host) {
return host.replace('.', '[.]').replace('*', '[^/]*')
}
function computeSafelinksRegexp() {
return new RegExp('(?:' +
safelinksPatterns.map(
({host, path}) =>
`(?:https?://${escapeHostname(host)}/${path})`).join('|') +
')',
'gi');
}
const safelinksRegexp = computeSafelinksRegexp()
......@@ -28,6 +28,7 @@ browser.composeScripts.register({
],
js: [
{file: "mutation.js"},
{file: "patterns.js"},
{file: "links.js"},
{file: "popup.js"},
{file: "compose.js"}
......@@ -40,6 +41,7 @@ browser.messageDisplayScripts.register({
],
js: [
{file: "mutation.js"},
{file: "patterns.js"},
{file: "links.js"},
{file: "popup.js"},
{file: "display.js"},
......
......@@ -7,6 +7,7 @@
},
"background": {
"scripts": [
"patterns.js",
"links.js",
"menu.js",
"background.js"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment