- Author:
- emna
- Posted:
- April 16, 2009
- Language:
- HTML/template
- Version:
- Not specified
- 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:[email protected]"|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
- Bootstrap Accordian by Netplay4 5 years, 11 months ago
- Bootstrap theme for django-endless-pagination? by se210 8 years, 11 months ago
- Bootstrap theme for django-endless-pagination? by se210 8 years, 11 months ago
- Reusable form template with generic view by roldandvg 9 years ago
- Pagination Django with Boostrap by guilegarcia 9 years, 2 months ago
Comments
Please login first before commenting.