From 33d3d336f8f4ea876bf47d0d467778bb288cee03 Mon Sep 17 00:00:00 2001 From: Holger Just Date: Fri, 15 Jan 2016 17:56:37 +0100 Subject: [PATCH] Further obfuscate the author's email address in the generated HTML --- helpers/middleman_casper_helpers.rb | 33 +++++++++++++++++++++++++++++ source/impressum.md.erb | 3 +-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/helpers/middleman_casper_helpers.rb b/helpers/middleman_casper_helpers.rb index b017bf6..3b3efde 100644 --- a/helpers/middleman_casper_helpers.rb +++ b/helpers/middleman_casper_helpers.rb @@ -128,6 +128,39 @@ module MiddlemanCasperHelpers def author_path "#{blog.options.prefix.to_s}/author/#{blog_author.name.parameterize}/" end + def author_email_link + raw_email = blog_author.email.to_s.scan(/&#\d+;/).map{|c| c[2..-2].to_i}.pack('U*') + + # We emit the email address as HTML encoded ROT47 string + email = raw_email.tr('!-~', 'P-~!-O').unpack('U*').map{ |code| "&##{code.to_s};"}.join + + <<-HTML.tap { |s| s.gsub!(/^#{s.scan(/^[ \t]+(?=\S)/).min}/, '') }.html_safe + E-Mail: + + + HTML + end def og_type if is_blog_article? diff --git a/source/impressum.md.erb b/source/impressum.md.erb index 2d797ad..ff53348 100644 --- a/source/impressum.md.erb +++ b/source/impressum.md.erb @@ -11,8 +11,7 @@ Frankfurter Allee 53
10247 Berlin
GERMANY -Website: <%= link_to blog_author.website.sub(%r{^https?://}, ''), blog_author.website %>
-E-Mail: <%= blog_author.email %> +

<%= author_email_link %>

Diese Daten dürfen nicht zu Werbezwecken genutzt werden.
This data may not be used for advertising purposes.