<?xml version="1.0" encoding="UTF-8"?>


<rdf:RDF xmlns:ns5="http://lojjic.net/ns/rdf/comments/" xmlns:ns4="http://purl.org/dc/terms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:ns2="http://lojjic.net/ns/rdf/blog/">

<rdf:Description rdf:about="http://lojjic.net/blog/20030828-142754">
	<ns2:entry-date rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2003-08-28T14:27:54-07:00</ns2:entry-date>
</rdf:Description>

<rdf:Description rdf:about="http://lojjic.net/ns/rdf/blog/entry-date">
	<rdfs:domain rdf:resource="http://lojjic.net/ns/rdf/blog/Entry" />
</rdf:Description>

<rdf:Description rdf:about="http://lojjic.net/blog/20030828-142754">
	<rdf:type rdf:resource="http://lojjic.net/ns/rdf/blog/Entry" />
	<ns2:entry-title rdf:datatype="http://www.w3.org/2001/XMLSchema#normalizedString">Accessible Email Obfuscation</ns2:entry-title>
</rdf:Description>

<rdf:Description rdf:about="http://lojjic.net/ns/rdf/blog/entry-title">
	<rdfs:domain rdf:resource="http://lojjic.net/ns/rdf/blog/Entry" />
</rdf:Description>

<rdf:Description rdf:about="http://lojjic.net/blog/20030828-142754">
	<ns2:entry-content rdf:parseType="Literal"><p xmlns="http://www.w3.org/1999/xhtml">As I understand it, the Sobig virus making rounds recently propagates itself by looking not only in your address book, but also in any web pages cached on the system.  So if you are a website operator who puts a <code xmlns="http://www.w3.org/1999/xhtml">mailto:</code> link to your email address on your site, you may receive copies of the virus not only from friends who have you in their address book, but from <em xmlns="http://www.w3.org/1999/xhtml">any infected user who visits your site</em>.  Not to mention the bucketloads of spam you probably already receive from spammers who crawl the web looking for ripe email addresses to harvest.</p>
<p xmlns="http://www.w3.org/1999/xhtml">There are ways to avoid both these problems, though.  One common obfuscation technique is to do something like <code xmlns="http://www.w3.org/1999/xhtml" class="block">&lt;script&gt;document.write(&apos;&lt;a &apos; + &apos;hre&apos; + &apos;f=&quot;mai&apos; + &apos;lto&apos; + &apos;:jj@&apos; + &apos;lojji&apos; + &apos;c.n&apos; + &apos;et&quot;&gt;j&apos; + &apos;j@l&apos; + &apos;ojjic.n&apos; + &apos;et&lt;/a&gt;&apos;);&lt;/script&gt;</code>  Spambots don&apos;t recognize that as an email link, so they ignore it.  It works, but there&apos;s a big problem: it isn&apos;t accessible.  Anyone without scripting enabled won&apos;t see anything.</p>
<p xmlns="http://www.w3.org/1999/xhtml">My approach to obfuscation is different: put the email address in the HTML as plain text, but using slightly different characters so that spambots won&apos;t recognize it but a human still can.  Then use a script to transform the plain text into a full-fledged <code xmlns="http://www.w3.org/1999/xhtml">mailto:</code> link.</p>
<p xmlns="http://www.w3.org/1999/xhtml">Here&apos;s my script:</p>
<pre xmlns="http://www.w3.org/1999/xhtml"><code xmlns="http://www.w3.org/1999/xhtml">function linkEmail() {
  if(!document.getElementsByTagName) return;
  var allElts = document.getElementsByTagName(&quot;*&quot;);
  if(allElts.length == 0 &amp;&amp; document.all) 
    allElts = document.all; //hack for IE5
  for(var i=0; i&lt;allElts.length; i++) {
    var elt = allElts[i];
    var className = elt.className || elt.getAttribute(&quot;class&quot;) 
      || elt.getAttribute(&quot;className&quot;);
    if(className &amp;&amp; className.match(/\belectronic-mail\b/)
        &amp;&amp; elt.firstChild.nodeType == 3) {
      var addr = elt.firstChild.nodeValue;
      addr = addr.replace(/[ \[\{\(\|\/\\]at[ \]\}\)\|\/\\]/i, &quot;@&quot;)
        .replace(/[ \[\{\(\|\/\\](dot|period)[ \]\}\)\|\/\\]/gi, &quot;.&quot;);
      var lnk = document.createElement(&quot;a&quot;);
      lnk.setAttribute(&quot;href&quot;,&quot;mailto:&quot;+addr);
      lnk.appendChild(document.createTextNode(addr));
      elt.replaceChild(lnk, elt.firstChild);
    }
  }
}
window.onload = linkEmail;</code></pre>
<p xmlns="http://www.w3.org/1999/xhtml">That goes through the entire document, looking for any element with <code xmlns="http://www.w3.org/1999/xhtml">class=&quot;electronic-mail&quot;</code>.  It then parses the text contained by that element, interprets it as an email address, and creates a link in its place.  It should look something like <code xmlns="http://www.w3.org/1999/xhtml" class="block">&lt;span class=&quot;electronic-mail&quot;&gt;jj(at)lojjic(period)net&lt;/span&gt;</code> which is easily interpreted by a human as an email address, but a spambot won&apos;t see it.  That example shows just one of many possible formats; the parentheses can be replaced by {, }, [, ], |, \, /, a space, or any combination of those.  The <code xmlns="http://www.w3.org/1999/xhtml">period</code> can also be <code xmlns="http://www.w3.org/1999/xhtml">dot</code>.</p>
<p xmlns="http://www.w3.org/1999/xhtml">I&apos;ve been using this script (or a similar version) to create the email link in the sidebar on this site since it was launched (go ahead, view the source!)  To date I haven&apos;t received a single spam message to that address.  Feel free to use the script yourself, perhaps with a mention of where it came from.</p>
<hr xmlns="http://www.w3.org/1999/xhtml" />
<p xmlns="http://www.w3.org/1999/xhtml"><em xmlns="http://www.w3.org/1999/xhtml">Update:</em> Thanks to <a xmlns="http://www.w3.org/1999/xhtml" href="http://cde.berkeley.edu/people/justinmakeig/">Justin Makeig</a> for pointing out a bug in the script: by adding a &quot;g&quot; flag to the regular expression for the &quot;dot&quot;, addresses with more than one dot are now supported. Justin also informs me that he will be making use of the script on the new website for UC Berkeley&apos;s <a xmlns="http://www.w3.org/1999/xhtml" href="http://cde.berkeley.edu/">Center for Document Engineering</a>.</p>
<hr xmlns="http://www.w3.org/1999/xhtml" />
<p xmlns="http://www.w3.org/1999/xhtml"><em xmlns="http://www.w3.org/1999/xhtml">Update 2:</em> I&apos;ve created an <a xmlns="http://www.w3.org/1999/xhtml" href="http://lojjic.net/blog/20040123-114122.rdf.html"><acronym xmlns="http://www.w3.org/1999/xhtml" title="eXtensible Binding Language">XBL</acronym> version of this script</a>.</p></ns2:entry-content>
</rdf:Description>

<rdf:Description rdf:about="http://lojjic.net/ns/rdf/blog/entry-content">
	<rdfs:domain rdf:resource="http://lojjic.net/ns/rdf/blog/Entry" />
</rdf:Description>

<rdf:Description rdf:about="http://lojjic.net/blog/20030828-142754">
	<ns2:entry-subject rdf:resource="http://lojjic.net/blog/subjects/scripting" />
</rdf:Description>

<rdf:Description rdf:about="http://lojjic.net/ns/rdf/blog/entry-subject">
	<rdfs:domain rdf:resource="http://lojjic.net/ns/rdf/blog/Entry" />
</rdf:Description>

<rdf:Description rdf:about="http://lojjic.net/blog/20030828-142754">
	<ns4:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#long">1139767943</ns4:modified>
</rdf:Description>

<rdf:Description rdf:about="http://purl.org/dc/terms/modified">
	<rdfs:domain rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource" />
</rdf:Description>

<rdf:Description rdf:about="http://lojjic.net/blog/20030828-142754">
	<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource" />
</rdf:Description>

<rdf:Description rdf:about="http://www.w3.org/1999/02/22-rdf-syntax-ns#type">
	<rdfs:domain rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource" />
</rdf:Description>

<rdf:Description rdf:about="http://lojjic.net/blog/20030828-142754">
	<rdf:type rdf:resource="http://lojjic.net/ns/rdf/comments/CommentableResource" />
	<ns5:allow-comments rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</ns5:allow-comments>
</rdf:Description>

<rdf:Description rdf:about="http://lojjic.net/ns/rdf/comments/allow-comments">
	<rdfs:domain rdf:resource="http://lojjic.net/ns/rdf/comments/CommentableResource" />
</rdf:Description>

<rdf:Description rdf:about="http://lojjic.net/blog/20030828-142754">
	<ns5:comments rdf:nodeID="node12prv3hscx107" />
</rdf:Description>

<rdf:Description rdf:about="http://lojjic.net/ns/rdf/comments/comments">
	<rdfs:domain rdf:resource="http://lojjic.net/ns/rdf/comments/CommentableResource" />
</rdf:Description>

<rdf:Description rdf:nodeID="node12prv3hscx107">
	<rdf:type rdf:resource="http://lojjic.net/ns/rdf/comments/CommentList" />
	<rdf:_1 rdf:resource="http://lojjic.net/blog/20030828-142754/comment-20050202-160716" />
	<rdf:_2 rdf:resource="http://lojjic.net/blog/20030828-142754/comment-20050317-200449" />
	<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource" />
	<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq" />
	<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Container" />
	<rdfs:member rdf:resource="http://lojjic.net/blog/20030828-142754/comment-20050202-160716" />
	<rdfs:member rdf:resource="http://lojjic.net/blog/20030828-142754/comment-20050317-200449" />
</rdf:Description>

</rdf:RDF>
