Skip to content

Commit

Permalink
Merge pull request #19 from phavekes/feature/TB78
Browse files Browse the repository at this point in the history
Switch to messageDisplayScripts to be compatible with TB78
  • Loading branch information
phavekes authored Jan 9, 2021
2 parents 2caae71 + 52d386e commit 2510cd0
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 186 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This plugin will change the URL back to the original value.

Version 1.* is compatible with Thunderbird 60.*

Version 2.* is compatible with Thunderbird 68-73
Version 2.* is compatible with Thunderbird 68+

Version 3.* is compatible with Thunderbird 78+

No support for TB version 78 yet
2 changes: 1 addition & 1 deletion makexpi.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

NAME=unmangleOutlookSafelinks
VERSION=2.0.2
VERSION=3.0.0
rm -Rf */*~

ZIPFILE=${NAME}-${VERSION}.xpi
Expand Down
6 changes: 6 additions & 0 deletions src/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let registeredScripts = browser.messageDisplayScripts.register({
js: [{
file: "display.js"
}, ],
});
console.log('Registerd messageDisplayScript; unmangle outlook safelinks ready.');
54 changes: 0 additions & 54 deletions src/bootstrap.js

This file was deleted.

1 change: 0 additions & 1 deletion src/chrome.manifest

This file was deleted.

115 changes: 0 additions & 115 deletions src/chrome/content/unmangle.jsm

This file was deleted.

54 changes: 54 additions & 0 deletions src/display.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//loop over all html links
function unmangleAllLinks() {
var links = document.body.getElementsByTagName("a");
for (var i = 0; i < links.length; i++) {
unmangleLink(links[i]);
}
}

//fix a link
function unmangleLink(a) {
if (a.hostname.endsWith('safelinks.protection.outlook.com') == false) {
return;
}
//remember original url
var orgUrl = a.href;

var doInner = false;

// This is a pretty lame test
if (a.innerHTML.includes('safelinks.protection.outlook.com')) {
doInner = true;
}

var terms = a.search.replace(/^\?/, '').split('&');

for (var i = 0; i < terms.length; i++) {
var s = terms[i].split('=');
if (s[0] == 'url') {
a.href = decodeURIComponent(s[1]);
a.title = "Outlook Unmangled from: " + orgUrl;
console.log("Rewrote "+orgUrl+" to "+a.href);

if (doInner) {
a.textContent = a.href;
}
return;
}
}
}

function decodeURI(match, p1, offset, string) {
return decodeURIComponent(p1);
}

function unmangleContent(text) {
text = text.replace(/https:\/\/[^\.]+\.safelinks\.protection\.outlook\.com\/\?url=([^&]*)&[^>\s]*/g, decodeURI);
return text;
}

console.log("Start unmangle links")
//First, unmangle the links
unmangleAllLinks()
//Then unmangle any texts :
//document.body.innerHTML = unmangleContent(document.body.innerHTML);
File renamed without changes
File renamed without changes
29 changes: 16 additions & 13 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
{
"manifest_version": 2,
"name": "Unmangle Outlook Safelinks",
"description": "Thunderbird plugin to unmangle Outlook Protection Safelinks\n\nBased upon https://github.com/mbattersby/unmangleOutlookSafelinks\nOriginal version by [email protected]\n\nUsers of Office365 who have Advanced Thread Protection enabled will change\nall URL's in emails to redirect them to an Microsoft filter before opening.\nThis will leak information to Microsoft and makes it impossible to see if\nthe original URL was safe to open.\n\nE.g. a link to\n\thttp://phishingsite.fake.ru/you/are/hacked.php \nwill show as\n\thttps://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fphishingsite.fake.ru%2Fyou%2Fare%2Fhacked.phpdata=02%7C01%7Csender.mail%40domain.tld%7C8177af7905a4406ecae208d5dc1fb7c9%7C87c50b582ef2423da4dbaedde7c84efcfa%7C0%7C0%7C63453351150545403+sdata=Te0O1xGxxxULxdzbxQ%2xxxyql2QjTt4Ken%2F00JB%2BV%2FPUA%3D+reserved=0\n\nand will not be recognized by a user as dangerous.\n\nThis plugin will change the URL back to the original value.\n\nContributors:\nPeter Havekes - [email protected]\nJan Kiszka - [email protected]\nPetros Koutsolampros",
"version": "3.0.0",
"author": "Peter Havekes",
"applications": {
"gecko": {
"id": "[email protected]",
"strict_min_version": "68.0"
"strict_min_version": "78.0"
}
},
"name": "Unmangle Outlook Safelinks",
"author": "[email protected]",
"developer": {
"name": "Peter Havekes"
},
"homepage_url": "https://github.com/phavekes/unmangleOutlookSafelinks",
"description": "Thunderbird plugin to unmangle Outlook Protection Safelinks\n\nBased upon https://github.com/mbattersby/unmangleOutlookSafelinks\nOriginal version by [email protected]\n\nUsers of Office365 who have Advanced Thread Protection enabled will change\nall URL's in emails to redirect them to an Microsoft filter before opening.\nThis will leak information to Microsoft and makes it impossible to see if\nthe original URL was safe to open.\n\nE.g. a link to\n\thttp://phishingsite.fake.ru/you/are/hacked.php \nwill show as\n\thttps://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fphishingsite.fake.ru%2Fyou%2Fare%2Fhacked.phpdata=02%7C01%7Csender.mail%40domain.tld%7C8177af7905a4406ecae208d5dc1fb7c9%7C87c50b582ef2423da4dbaedde7c84efcfa%7C0%7C0%7C63453351150545403+sdata=Te0O1xGxxxULxdzbxQ%2xxxyql2QjTt4Ken%2F00JB%2BV%2FPUA%3D+reserved=0\n\nand will not be recognized by a user as dangerous.\n\nThis plugin will change the URL back to the original value.\n\nContributors:\nPeter Havekes - [email protected]\nJan Kiszka - [email protected]\nPetros Koutsolampros",
"version": "2.0.2",
"icons": {
"32": "chrome/content/icon.png"
"64": "images/icon64.png",
"48": "images/icon48.png"
},
"background": {
"scripts": [
"background.js"
]
},
"legacy": {
"type" : "bootstrap"
}
"permissions": [
"messagesModify",
"messagesRead"
]
}
Binary file added unmangleOutlookSafelinks-3.0.0.xpi
Binary file not shown.

0 comments on commit 2510cd0

Please sign in to comment.