✨feat: add base64 encoded email protection #110
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR
Introduced a feature to protect email addresses from spambots using base64 encoding. Emails can be added in plain text or pre-encoded to prevent scraping, especially from public repos. Decoding occurs client-side via JavaScript.
Description
This PR introduces a feature that protects email addresses from spambots by optionally allowing them to be base64 encoded, either to hide them from potential scraping in public repos or for in-site protection.
The email addresses are then decoded on the client side using ~400 bytes of JavaScript, ensuring genuine users see the actual email, while offering a level of protection against spambots that don't execute JavaScript.
Key features
Flexible configuration in TOML:
encode_plaintext_email
) to encode the plaintext email on the website.JavaScript decoding:
Tera temple integration:
Changes made
Updated TOML configuration:
email
andencode_plaintext_email
configuration options to handle emails, along with comments explaining the features.Added JavaScript decoder:
decodeMail.min.js
(anddecodeMail.js
, for reference) which contains functions to decode base64 emails and update thehref
of email links.Enhancements in Tera template:
footer.html
template to incorporate the encoded email functionality.Documentation:
How to use
E-mail decoding for spambot protection: If you wish to guard your email against spambots scraping from your website, simply set the configuration
encode_plaintext_email = true
. You can set theemail
variable to your actual e-mail, unless…Public repository protection: For those who have their sites on public repositories and wish for an additional layer of security, it's recommended to pre-encode your
email
into a base64 string before adding it to the configuration. This ensures that even if spambots scrape the repository, they won't get the plain-text email.To encode your email in base64, you can use online tools or run from your terminal:
printf '[email protected]' | base64
.Inspiration
This idea is based off (or copied, at least the concept) the Abridge theme.