
Security News
NVD Quietly Sweeps 100K+ CVEs Into a “Deferred” Black Hole
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
django-mailprotector
Advanced tools
A reusable Django app that protects email addresses and phone numbers, in various ways.
A reusable Django app that protects email addresses and phone numbers, in various ways. Django 1.8+, no further dependencies.
To get the latest stable release from PyPi
pip install django-mailprotector
Add mailprotector
to your INSTALLED_APPS
INSTALLED_APPS = (
...,
'mailprotector',
)
If you want to use the mailprotector_textblock
tag, you'll need to have beautifulsoup4 installed.
Before your tags/filters are available in your templates, load them by using
{% load mailprotector_tags %}
Then either email address after email address:
{% mailprotector 'your@domain.com' link_text='link text' css_class='stylish' %}
Or as text block, for example from a rich text editor:
{% mailprotector_textblock object.richtext css_class='stylish' %}
MAILPROTECTOR_MODE = 'munger|munger_link_only'
This settings defines the protection algorithm used. Each has benefits and drawbacks...
munger: basic "munging" algo, replacing a mailto/tel link with a span, that gets filled with a new link. drawbacks: mailto are in dom, after a page is fully rendered with js (for example, with phantomjs). the link text can only be basic text, no html is possible. existing attributes (in textblock mode) will be removed (including class!) .
munger_link_only: "munging", but only with the href. benefits: all link attributes as well as link text including html is conserved drawbacks: for safety, emails and phone numbers (not yet) are protected in a basic way: @ = ' (at) ', . = ' . '
email_pattern = r'\b[-.\w]+@[-.\w]+.[a-z]{2,6}\b' phone_pattern = r'\d{3} \d{3} \d{2} \d{2}'
MAILPROTECTOR_EMAIL_PATTERN = re.compile(r'(' + email_pattern + r')') MAILPROTECTOR_PHONE_PATTERN = re.compile(r'(' + phone_pattern + r')')
For the mailprotector_textblock tag, you can yourself define the used regexes. Following are the
defaults. If any of these are None
, it is omitted during protection.
WARNING: The default phone pattern is going to change to a more
international default!
./manage.py runserver
.tox
If you want to contribute to this project, please perform the following steps
# Fork this repository
# Clone your fork
mkvirtualenv -p python2.7 django-mailprotector
pip install -r test_requirements.txt
git checkout -b feature_branch
# Implement your feature and tests
git add . && git commit
git push -u origin feature_branch
# Send us a pull request for your feature branch
FAQs
A reusable Django app that protects email addresses and phone numbers, in various ways.
We found that django-mailprotector demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Research
Security News
Lazarus-linked threat actors expand their npm malware campaign with new RAT loaders, hex obfuscation, and over 5,600 downloads across 11 packages.
Security News
Safari 18.4 adds support for Iterator Helpers and two other TC39 JavaScript features, bringing full cross-browser coverage to key parts of the ECMAScript spec.