diff --git a/build.sh b/build.sh index ed0e102..cf39783 100755 --- a/build.sh +++ b/build.sh @@ -10,7 +10,7 @@ mkdir build mkdir build/chrome cd chrome -zip -r $filename.jar . -i *.js *.xul *.png *.gif *.rdf *.css *.dtd *.properties +zip -r $filename.jar . -i *.js *.xul *.png *.gif *.rdf *.css *.dtd *.properties *.svg mv $filename.jar ../build/chrome/ cd .. diff --git a/chrome/content/images/hop.svg b/chrome/content/images/hop.svg new file mode 100644 index 0000000..53d143b --- /dev/null +++ b/chrome/content/images/hop.svg @@ -0,0 +1,126 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/chrome/content/images/ipv6.svg b/chrome/content/images/ipv6.svg new file mode 100644 index 0000000..aea75bd --- /dev/null +++ b/chrome/content/images/ipv6.svg @@ -0,0 +1,42 @@ + + + + + + + + + + diff --git a/chrome/content/images/mailhops-logo.svg b/chrome/content/images/mailhops-logo.svg new file mode 100644 index 0000000..df29dcb --- /dev/null +++ b/chrome/content/images/mailhops-logo.svg @@ -0,0 +1,128 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/chrome/content/images/w3w.png b/chrome/content/images/w3w.png new file mode 100644 index 0000000..2bd4550 Binary files /dev/null and b/chrome/content/images/w3w.png differ diff --git a/chrome/content/mailhops.js b/chrome/content/mailhops.js index a038be3..795f756 100644 --- a/chrome/content/mailhops.js +++ b/chrome/content/mailhops.js @@ -203,10 +203,15 @@ mailHops.loadHeaderData = function() }; mailHops.getRoute = function(){ -//IP regex -var regexIp=/(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)(\/(?:[012]\d?|3[012]?|[456789])){0,1}$/; -var regexAllIp = /(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)(\/(?:[012]\d?|3[012]?|[456789])){0,1}/g; - + //IP regex + var regexIp=/(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)(\/(?:[012]\d?|3[012]?|[456789])){0,1}$/; + var regexAllIp = /(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)(\/(?:[012]\d?|3[012]?|[456789])){0,1}/g; + + // TODO test IPV6 regex for Received headers, currently only used for X-Originating-IP + // IPv6 addresses including compressed and IPv4-embedded variants (RFC 2373) + // http://regexlib.com/REDetails.aspx?regexp_id=2919 + var regexIPV6 = /(::|(([a-fA-F0-9]{1,4}):){7}(([a-fA-F0-9]{1,4}))|(:(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){1,6}:)|((([a-fA-F0-9]{1,4}):)(:([a-fA-F0-9]{1,4})){1,6})|((([a-fA-F0-9]{1,4}):){2}(:([a-fA-F0-9]{1,4})){1,5})|((([a-fA-F0-9]{1,4}):){3}(:([a-fA-F0-9]{1,4})){1,4})|((([a-fA-F0-9]{1,4}):){4}(:([a-fA-F0-9]{1,4})){1,3})|((([a-fA-F0-9]{1,4}):){5}(:([a-fA-F0-9]{1,4})){1,2}))/; + var headReceived = mailHops.headers.extractHeader ( "Received" , true ) ; var headXOrigIP = mailHops.headers.extractHeader ( "X-Originating-IP" , false ) ; //auth box @@ -265,9 +270,16 @@ var regexAllIp = /(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{ } //get the originating IP address if(headXOrigIP){ - var ip = headXOrigIP.match(regexAllIp); - if(ip != null && ip.length != 0 && all_ips.indexOf(ip[0])==-1) - all_ips.unshift( ip[0] ); + //remove brackets + headXOrigIP = headXOrigIP.replace('[','').replace(']',''); + //IPV6 check + if(headXOrigIP.indexOf(':') !== -1 && headXOrigIP.match(regexIPV6)){ + all_ips.unshift( headXOrigIP ); + } else { + var ip = headXOrigIP.match(regexAllIp); + if(ip != null && ip.length != 0 && all_ips.indexOf(ip[0])==-1) + all_ips.unshift( ip[0] ); + } } if ( all_ips.length != 0 ){ mailHops.lookupRoute ( all_ips ) ; @@ -277,8 +289,7 @@ var regexAllIp = /(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{ }; //another ip check, dates will throw off the regex mailHops.testIP = function(ip,header){ - var retval = true - , disAllowLastChars = ['?',';']; + var retval = true; try { @@ -290,7 +301,7 @@ mailHops.testIP = function(ip,header){ if(firstchar.match(/\.|\d|\-/) || lastchar.match(/\.|\d|\-/) || ( firstchar == '?' && lastchar == '?' ) - || lastchar.indexOf(disAllowLastChars) !== -1){ + || lastchar == ';'){ return null; } else if(header.indexOf('['+ip+']') !== -1 || header.indexOf('('+ip+')') !== -1){ @@ -688,7 +699,21 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){ mailHops.mailhopsDataPaneDNSBL.style.display = 'block'; } - } + // if(response.route[i].ip.indexOf(':') !== -1){ + // var ipv6 = document.createElement('label'); + // ipv6.setAttribute('class','dataPaneAddressitem mailhopsipv6'); + // ipv6.setAttribute('value','IPV6'); + // mailHops.resultDetails.appendChild(ipv6); + // } + + if(response.route[i].w3w){ + var w3w = document.createElement('label'); + w3w.setAttribute('class','dataPaneAddressitem mailhopsW3w'); + w3w.setAttribute('value',response.route[i].w3w.words.join('.')); + w3w.setAttribute('onclick','mailHops.launchExternalURL("'+response.route[i].w3w.url+'");'); + mailHops.resultDetails.appendChild(w3w); + } + } } if(image.indexOf('local')!=-1) { @@ -964,13 +989,15 @@ mailHops.addCommas = function(nStr){ } return x1 + x2; }; +mailHops.launchExternalURL = function(url){ + var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance().QueryInterface(Components.interfaces.nsIMessenger); + messenger.launchExternalURL(url); +}; mailHops.launchWhoIs = function(ip){ - var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance().QueryInterface(Components.interfaces.nsIMessenger); - messenger.launchExternalURL('http://www.mailhops.com/whois/'+ip); + mailHops.launchExternalURL('http://www.mailhops.com/whois/'+ip); }; mailHops.launchSpamHausURL = function(ip){ - var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance().QueryInterface(Components.interfaces.nsIMessenger); - messenger.launchExternalURL('http://www.spamhaus.org/query/bl?ip='+ip); + mailHops.launchExternalURL('http://www.spamhaus.org/query/bl?ip='+ip); }; mailHops.launchMap = function(route){ diff --git a/chrome/skin/classic/mailhops.css b/chrome/skin/classic/mailhops.css index 45814e2..8e7b9b6 100644 --- a/chrome/skin/classic/mailhops.css +++ b/chrome/skin/classic/mailhops.css @@ -46,10 +46,11 @@ -webkit-border-radius: 5px; -khtml-border-radius: 5px; border-radius: 5px; - padding: 4px; + padding: 8px; + word-wrap: break-word; } -.mailhopsWeather, .mailhopsHost, .mailhopsSecureHost, .mailhopsSecure{ +.mailhopsHost, .mailhopsSecureHost, .mailhopsSecure, .mailhopsW3w { margin-left: 30px; padding-bottom: 2px; } @@ -69,14 +70,10 @@ background-repeat: no-repeat; } -.mailhopsWeatherPref{ - background-image: url(chrome://mailhops/content/images/weather/sun.png); - background-repeat: no-repeat; -} - -.mailhopsWeatherPref checkbox, .mailhopsHostPref checkbox, .mailhopsSecurePref checkbox{ - margin-left: 20px; - margin-top: 0px; +.mailhopsW3w { + background-image: url(chrome://mailhops/content/images/w3w.png); + background-repeat: no-repeat; + cursor: pointer; } .auth-item{ diff --git a/mailhops.xpi b/mailhops.xpi index 87f5eb8..ef2dc8b 100644 Binary files a/mailhops.xpi and b/mailhops.xpi differ