Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

HTML Obfusticate to hide email addresses

 [1/3] from: Al::Bri::xtra::co::nz at: 24-Apr-2003 18:10


HTML_Obfusticate: func [Plain [string! email!]] [ if not string? Plain [ Plain: to-string Plain ] map Plain function [Char [char!]] [Entity] [ Entity: to-integer Char rejoin [ "&#" any [ if Entity < 10 [ "00" ] if Entity < 100 [ #"0" ] "" ] Entity #";" ] ] ]
>> HTML_Obfusticate "mailto:Al[dot]Bri[at]xtra[dot]co[dot]nz"
== {&#109;&#097;&#105;&#108;&#116;&#111;&#058;&#065;&#108;&#046;&#066;&#1 14;&#105;&#064;&#120;&#116;&#114;&#097;&#046;&#099;&#111;&... Just a little something I've recently added to my eText software to automatically hide email addresses from spammers. Here's where I got the method and reasons for: http://www.cdt.org/speech/spam/030319spamreport.shtml Andrew Martin ICQ: 26227169 http://Valley.WebPictureBook.com/

 [2/3] from: brian:hawley at: 26-Apr-2003 11:32


Hey Andrew, At 06:10 PM 4/24/03 +1200, Andrew Martin wrote: (a useful function named HTML_Obfusticate) Here's a faster version that doesn't use map. HTML_Obfuscate: func [ Plain [string! email!] /local out ] [ ; No need to convert email to string out: make string! 6 * length? Plain foreach x Plain [ x: to-integer x out: insert out reduce [ "&#" any [ if x < 10 ["00"] if x < 100 [#"0"] "" ] x #";" ] ] head out ] Not that there's any problem with using map (that I know of, as I've never used it). I just know that this version is faster because it uses mostly natives, creates the destination string ahead of time, and doesn't recreate an inner function with every call. Watch out though: In current REBOL, a function's local variables will keep their references until the function is called again (non-recursively); in this case that means the converted string. If memory is a concern, these kind of things matter. Probably not when obfuscating email, though :) Now, off to check out map ! - Brian

 [3/3] from: Al::Bri::xtra::co::nz at: 27-Apr-2003 10:33

Re: HTML Obfuscate to hide email addresses


Brian Hawley wrote:
> Here's a faster version that doesn't use map.
And it's correctly spelled too! :) Thanks, Brian. I've updated my Values to use your version. Thanks again! Andrew Martin ICQ: 26227169 http://Valley.WebPictureBook.com/