forked from CGM_Public/pretix_original
* Include nix development enviornment * Obfuscate contact email addresses in shop HTML and deanonymize via JavaScript This change addresses #1907: "hide contact e-mail address in source code of a shop". - Contact email addresses rendered in public-facing templates are now obfuscated in the HTML source (e.g., replacing "@" with "[at]" and "." with "[dot]"). - A new JavaScript file is included in the relevant templates to automatically rewrite and restore the email address for users after the page loads. - This approach helps protect email addresses from basic harvesting bots and reduces spam, while keeping them accessible and user-friendly for human visitors. - The obfuscation and deanonymization logic is only applied to web templates, not to emails sent via pretix. This implementation follows the recommendations discussed in #1907, using a standardized, maintainable approach that’s compatible with pretix's asset pipeline and template structure. * Undo nix development environment for merge into main * convert complete mailto-link to HTML entities * remove gitignore noise * Update .gitignore * fix gitignore noise * Update .gitignore --------- Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
13
src/pretix/base/templatetags/anonymize_email.py
Normal file
13
src/pretix/base/templatetags/anonymize_email.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from django import template
|
||||
from django.utils.html import mark_safe
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter("anon_email")
|
||||
def anon_email(value):
|
||||
"""Replaces @ with [at] and . with [dot] for anonymization."""
|
||||
if not isinstance(value, str):
|
||||
return value
|
||||
value = value.replace("@", "[at]").replace(".", "[dot]")
|
||||
return mark_safe(''.join(['&#{0};'.format(ord(char)) for char in value]))
|
||||
Reference in New Issue
Block a user