Login

entity encoded email-address

Author:
emna
Posted:
April 16, 2009
Language:
HTML/template
Version:
Not specified
Tags:
email spam prevention
Score:
1 (after 1 ratings)

entity encoded string for a somewhat safer email-address.

this filter encodes strings to numeric entities, almost every standard-browsers decodes the entities and display them the right way.

needless to say that bots are smart, so this is not a 100% guaranteed spam prevention.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
@register.filter(name='secure_mail')
@stringfilter
def secure_mail(value):
    """
    Returns a somewhat safer email address
    
    Usage:
    
        {{ "mailto:me@domain.com"|secure_mail }}
    
    Outputs:
        
        mailto:me@domain.com
    
    """
    try:
        return "".join(["&#%s;" %(ord(c)) for c in value])
    except:
        return value
secure_mail.is_safe = True # because "&" is renderd with autoescape by default 

More like this

  1. Email Munger by cootetom 6 years, 5 months ago
  2. encode_mailto by santuri 8 years, 1 month ago
  3. Encode emails as URIs by fahhem 4 years, 10 months ago
  4. Template Tag to protect the E-mail address by end0 1 month, 4 weeks ago
  5. Email obfuscation filter using ROT13 by worksology 6 years, 2 months ago

Comments

Please login first before commenting.