diff --git a/shared/_locales/en/messages.json b/shared/_locales/en/messages.json index d2943ff0ce46620aa8ec19cae59ebf40c9264dbf..51cd374ffbeca1f72c635367c0e632bb103ed70a 100644 --- a/shared/_locales/en/messages.json +++ b/shared/_locales/en/messages.json @@ -1,6 +1,6 @@ { "extensionDescription": { - "message": "Correct the display and quoting of links mangled by Microsoft Defender for Office 365 Safe Links.", + "message": "Correct the display and quoting of links mangled by Microsoft Defender for Office 365 Safe Links or Barracuda Link Protection.", "description": "Description of the extension." }, diff --git a/shared/_locales/sv/messages.json b/shared/_locales/sv/messages.json index e33708e967e5b64b2d5fa819f3d3e6ef1a420bf1..0334a9b87df1ae295ee6fd3ee9080b613baaee09 100644 --- a/shared/_locales/sv/messages.json +++ b/shared/_locales/sv/messages.json @@ -1,6 +1,6 @@ { "extensionDescription": { - "message": "Korrigera visning och citering av länkar manglade av Microsoft Defender för Office 365 Safe Links.", + "message": "Korrigera visning och citering av länkar manglade av Microsoft Defender för Office 365 Safe Links eller Barracuda Link Protection.", "description": "Description of the extension." }, diff --git a/shared/patterns.js b/shared/patterns.js index a52e3c5364c27582f7bbc6c7c2e501d46acb880f..332d4f72a9ee997b90397b4b3cd3e6e9fd490edc 100644 --- a/shared/patterns.js +++ b/shared/patterns.js @@ -25,23 +25,52 @@ const safelinksPatterns = [ { + name: 'Microsoft Defender For Office 365 Safe Links', host: '*.safelinks.protection.outlook.com', path: '[?]url=([^&]+).*' }, { + name: 'Barracuda Link Protection', host: 'linkprotect.cudasvc.com', path: 'url[?]a=([^&]+).*' + }, + { + name: 'Proofpoint (v3)', + host: 'urldefense.com', + path: 'v3/_+([^_]+).*' } + // { + // name: 'Proofpoint (v2)', + // host: 'urldefense.proofpoint.com', + // path: 'v2/url[?]u=([^&]+).*', + // proc: (string) => string.replace('_', '/') + // } ]; + +/** + * Compute a list of url patterns from the link patterns. + * @returns {Array} - Array of patterns. + */ function computeSafelinksMatchPatterns() { return safelinksPatterns.map(({host, path}) => '*://' + host + '/*'); } + +/** + * Escape a hostname pattern for use in a regexp. + * @param {string} host - The host name pattern. + * @returns {string} A suitable regexp. + */ function escapeHostname(host) { return host.replace('.', '[.]').replace('*', '[^/]*') } + +/** + * Compute a regexp that matches all mangled links. + * @returns {RegExp} A regexp that matches all possible mangled links. + */ function computeSafelinksRegexp() { return new RegExp('(?:' + safelinksPatterns.map( @@ -51,4 +80,5 @@ function computeSafelinksRegexp() { 'gi'); } + const safelinksRegexp = computeSafelinksRegexp()