This plugin allows you to produce a mailto: email address link that is not easily "harvested" by web crawlers. The mailto: is encoded and javascript is used to decode it.
Usage#
- Add the obfust-mailto.jar in your WIB-INF/libs directory.
- Include the functions in the obfusticateMt.js into your jsp-common.js file
- Add uk.org.bhu.jspwiki.plugins to jspwiki.plugin.searchPath in your jspwiki.properties[1].
- in a page use: Email me at [{ObfusticateMailto email='test-user@tester.com'}], with the desired email address.
Details#
To avoid email-address "harvesting" by web crawlers, the mailto: is encoded and javascript is used to decode it. For example the input lineEmail me at [{ObfusticateMailto email='test-user@tester.com'}]
will produce a clickable email address similar to
Email me at test-user@tester.com
(but without the "outlink" image") in a browser. The source, however contains the following string, which gives no indication that the text is a mailto: URL.
Email me at <script>obfustMt("11 66 45 51 64 62 19 64 60 29 64 4 24 29 60 50 3 64 60 29 64 60 50 39 49 62 11");</script>
This is decoded by a simple javascript function. The coding is not cryptographically secure; it doesn't have to be as the only requirement is to make the decryption more difficult than manually viewing the page in a browser and copying the link! The numbers are just indexes into the array of characters in the decode function. This array contains the valid email characters from Wikipedia:E-mail address
plus the colon for the mailto: prefix.
If the plugin were to be used on a great number of sites someone might think it worthwhile adding a decoder to a crawler. To avoid this you can change the letter substitutions by running a generator class
java -cp obfust-mailto.jar uk.org.bhu.generator.Generator
This will produce an output like:
package uk.org.bhu.jspwiki.plugins;
public class EncDecData {
//This generated class goes with a corresponding javascript
//which must have the commented var decodeArray line copied into it
// var decodeArray = new Array('s', 'D', 'U', 'h', '^', '7', '*', '{', 'P', 'I', '!', 'm', '9', 'o', 'V', 'N', 'L', '=', '%', '3', '5', '@', ':', '-', 'u', '#', 'a', 'Y', '8', 'O', 'r', '|', 'H', 'R', 'w', 'n', '6', 'j', 'v', 'e', 'S', '}', 'X', '`', 'z', 'd', 'E', 'M', '$', '0', '.', 'q', 'Q', 'F', 'b', 'p', '?', 'c', '1', 'C', '&', 't', '~', 'G', '+', 'y', 'i', '2', '4', 'g', 'x', '/', 'T', 'K', 'A', 'Z', 'W', 'J', 'l', 'f', '\'' , '_', 'B', 'k');
public static final int[] LOOKUP_ARRAY = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, -1, 25, 48, 18, 60, 80, -1, -1, 6, 64, -1, 23, 50, 71, 49, 58, 67, 19, 68, 20, 36, 5, 28, 12, 22, -1, -1, 17, -1, 56, 21, 74, 82, 59, 1, 46, 53, 63, 32, 9, 77, 73, 16, 47, 15, 29, 8, 52, 33, 40, 72, 2, 14, 76, 42, 27, 75, -1, -1, -1, 4, 81, 43, 26, 54, 57, 45, 39, 79, 69, 3, 66, 37, 83, 78, 11, 35, 13, 55, 51, 30, 0, 61, 24, 38, 34, 70, 65, 44, 7, 31, 41, 62, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
}
This is the new version of EncDecData.java, which can be used to build a new version of the encoder. The substitutions will change every time the program is run. The line starting var decodeArray needs to be put into the decoding javascript function. You can change the encoding on an existing wiki by regenerating the .jar file and changing the javascript functions.
The decode function#
This function should be added to the jsp-common.js file (it is included in the .jar as obfusticateMt.js)
/**
** Included for Obfusticatemailto Plugin
**/
function decrypt_string(crypted_string) {
var decodeArray = new Array('5', 'Q', 'U', '@', '-', 'S', 'x', '4', '9', 'P', 'K', 'm', 'z', 'g', '*', 'q', 'D', 'v', 'X', ':', 'F', 'A', 'V', '!', 'u', '{', 'n', '0', '=', 's', '3', '1', '\'', 'R', '^', '6', 'k', 'Y', 'G', '.', '#', 'w', '`', 'H', '~', 'i', 'd', '&', '+', 'c', 'r', 'l', 'E', 'h', 'W', '}', 'O', '8', '7', 'J', 'e', '|', 'o', 'C', 't', 'L', 'a', 'M', 'b', 'B', '2', '/', '$', '%', '?', 'j', 'I', 'f', 'y', 'N', '_', 'T', 'Z', 'p');
var numbers = crypted_string.split(' ');
var decrypted_string = '';
for(var i in numbers) {
decrypted_string += decodeArray[[numbers[[i]];
}
return decrypted_string;
}
function obfustMt(crypted_string) {
var clearString = decrypt_string(crypted_string);
document.write("<a href=\""+clearString+ "\">"+clearString.substr(7)+"</a>");
}
Add new attachment
List of attachments
| Kind | Attachment Name | Size | Version | Date Modified | Author | Change note |
|---|---|---|---|---|---|---|
jar |
obfust-mailto.jar | 6.6 kB | 1 | 04-May-2007 12:49 | 213.38.213.226 | add plugin jar |
zip |
obfust-mailtosrc.zip | 3.6 kB | 1 | 04-May-2007 12:50 | 213.38.213.226 | source |
js |
obfusticateMt.js | 0.9 kB | 1 | 04-May-2007 12:50 | 213.38.213.226 | js - also included in jar |