/usr/share/vim/cream/addons/cream-email-munge.vim is in cream 0.43-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | "
" cream-email-munge.vim -- Munge an email address
"
" Cream -- An easy-to-use configuration of the famous Vim text editor
" [ http://cream.sourceforge.net ] Copyright (C) 2001-2011 Steve Hall
"
" License:
" This program is free software; you can redistribute it and/or modify
" it under the terms of the GNU General Public License as published by
" the Free Software Foundation; either version 2 of the License, or
" (at your option) any later version.
" [ http://www.gnu.org/licenses/gpl.html ]
"
" This program is distributed in the hope that it will be useful, but
" WITHOUT ANY WARRANTY; without even the implied warranty of
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
" General Public License for more details.
"
" You should have received a copy of the GNU General Public License
" along with this program; if not, write to the Free Software
" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
" 02111-1307, USA.
"
" Date: 2003-01-23
" Version: 0.3
" Source: http://vim.sourceforge.net/scripts/script.php?script_id=538
" Author: Steve Hall [ digitect@mindspring.com ]
"
" Description:
" Posted email addresses are regularly harvested and processed by
" automated web search tools. These addresses often end up added or
" sold to bulk email lists so that the unsuspecting address owner
" receives large quantities of unsolicited email, also known as Spam.
"
" To avoid having one's email address harvested in this way, it can be
" "munged", or made unrecognizable by the automated system while still
" appearing as an email address to any human reader. Examples include:
"
" unmunged:
" username@domain.com
"
" munged, separator type:
" <username>·<domain>·<com>
" |username|at|domain|dot|com|
"
" munged, substitution type:
" useNrnaOme@SdomPainA.coMm (remove "NOSPAM" to email)
" useSrnPamAe@MdoFmaRinE.cEom (remove "SPAMFREE" to email)
"
" munged, completion type:
" usernam____n.com (insert "e@domai" to email)
"
" This script provides a visual mode mapping Shift+F12 which will
" munge any selected email address per the first two examples above.
" (The second two methods are on the ToDo.) The script's main
" function:
"
" Cream_email_munge()
"
" will also return a munged address if passed a valid email, like:
"
" let mymunge = Cream_email_munge("username@domain.com")
"
" Installation:
" * Drop this file into your plugins directory and (re)start Vim.
"
" ChangeLog:
"
" 0.3
" * Randomized number of blanks in completion-type
" * Removed lengthy "to email" from non-seperator munges.
" * Other minor tweaking
"
" 0.2a
" * Added omitted missing <CR> to visual mode mapping
"
" 0.2
" * Added substitution- and completion-type munging
"
" 0.1
" * Initial release
" register as a Cream add-on
if exists("$CREAM")
call Cream_addon_register(
\ 'Email Munge',
\ 'Make an email spam resistant',
\ 'Protect an email address from web bots by munging it into computer indecipherable form that is still human readable. Example: {creamforvim} * {mindspring} * {com}',
\ 'Email Munge',
\ '<Nil>',
\ '<C-u>call Cream_email_munge("v")'
\ )
else
vmap <silent> <S-F12> :<C-u>call Cream_email_munge("v")<CR>
endif
function! Cream_email_munge(email)
" returns a randomly munged variation of any email address passed
" arguments: [any valid email address] returns munged
" "v" implies visual mode call, munges current selection
" if visual mode, munge selection
if a:email == "v"
normal gv
normal "xy
normal gv
let myemail = @x
else
let myemail = a:email
endif
" get random number (last two digits of localtime(), 00-99)
let rnd1 = matchstr(localtime(), '..$') + 0
" get random number, boolean (0 or 1)
let rnd2 = rnd1[1] % 2
" get random number, boolean (0 or 1)
" (uses tens of seconds register of localtime())
let rnd3 = rnd1[0] % 2
" 50%
if rnd2 == 0
" do separator-type munge
let myemail = s:Cream_email_munge_separate(myemail, rnd1)
else
" 25%
if rnd3 == 0
" do substitution-type munge
let myemail = s:Cream_email_munge_substitute(myemail, rnd1)
" 25%
else
" do substitution-type munge
let myemail = s:Cream_email_munge_completion(myemail, rnd1)
endif
endif
" if visual mode, paste back over
if a:email == "v"
let @x = myemail
normal "xp
normal gv
else
return myemail
endif
endfunction
function! s:Cream_email_munge_separate(email, random)
" return separator-type munge of passed email address
" Example: {username}at{domain}dot{com}
let myemail = a:email
let rnd1 = a:random
" munge separators, switch every second
if rnd1[1] % 5 < 1
let sep1 = "|"
let sep2 = "|"
elseif rnd1[1] % 5 < 2
let sep1 = "["
let sep2 = "]"
elseif rnd1[1] % 5 < 3
let sep1 = "{"
let sep2 = "}"
elseif rnd1[1] % 5 < 4
let sep1 = "<"
let sep2 = ">"
else
let sep1 = "("
let sep2 = ")"
endif
" replace @ and . characters (most times)
" series 0-24 (25 possibilities)
" 32% (8/25)
if rnd1 % 25 < 8
let at = sep2 . "AT" . sep1
let dot = sep2 . "DOT" . sep1
" 16% (4/25)
elseif rnd1 % 25 < 12
let at = sep2 . " " . sep1
let dot = sep2 . " " . sep1
" 12% (3/25)
elseif rnd1 % 25 < 15
let at = sep2 . "(a)" . sep1
let dot = sep2 . "(d)" . sep1 " this is Dec.183, not period!
" 12% (3/25)
elseif rnd1 % 25 < 18
let at = sep2 . "(A)" . sep1
let dot = sep2 . "*" . sep1
" 28% (7/25)
else
let at = sep2 . "@" . sep1
let dot = sep2 . "." . sep1
endif
let myemail = substitute(myemail, "@", at, "g")
let myemail = substitute(myemail, "\\.", dot, "g")
let myemail = sep1 . myemail . sep2
return myemail
endfunction
function! s:Cream_email_munge_substitute(email, random)
" return substitution-type munge of passed email address
" Example: usNerOnameS@dPomAainM.com [remove NOSPAM to email]
let myemail = tolower(a:email)
let rnd1 = a:random
if rnd1[0] < 5
let spliceword = "NOSPAM"
else
let spliceword = "SPAMFREE"
endif
" * divide email length by spliceword length to obtain interval
let interval = strlen(myemail) / strlen(spliceword)
" splice in word at interval
let strfirst = ""
let strlast = ""
let pos = (interval / 2) - interval + 1
let i = 0
while i < strlen(spliceword)
let pos = pos + interval + 1
" get first part
let strfirst = strpart(myemail, 0, pos)
" get last part
let strlast = strpart(myemail, pos)
" concatenate
let myemail = strfirst . spliceword[i] . strlast
let i = i + 1
endwhile
return myemail . " (remove \"" . spliceword . "\")"
endfunction
function! s:Cream_email_munge_completion(email, random)
" Example: userna____main.com [fill in blank with "me@do"]
let myemail = a:email
" random is (1 - 5) - 1, based on tens of seconds register of localtime()
let rnd1 = (a:random[0] % 5) + 3
let pos = match(myemail, "@") - (a:random[1] % 5 / 2)
let strfirst = strpart(myemail, 0, pos)
let strmiddle = strpart(myemail, pos, rnd1)
let strlast = strpart(myemail, pos + rnd1)
" get 3-5 blanks
let myblanks = "__"
let i = 0
while i < a:random[1] % 3
let myblanks = myblanks . "_"
let i = i + 1
endwhile
return strfirst . myblanks . strlast . " (insert \"" . strmiddle . "\")"
endfunction
|