1
0
mirror of https://github.com/meineerde/holgerjust.de.git synced 2026-02-21 11:02:03 +00:00

Further obfuscate the author's email address in the generated HTML

This commit is contained in:
Holger Just 2016-01-15 17:56:37 +01:00
parent 92733d3fa1
commit 33d3d336f8
2 changed files with 34 additions and 2 deletions

View File

@ -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:
<script type="text/javascript">
(function() {
function decodeHTMLEntities(str) {
if(str && typeof str === 'string') {
var e = document.createElement('div');
e.innerHTML = str;
str = e.innerHTML;
e.remove();
}
return str;
}
function encodeHTMLEntities(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
buf.unshift(['&#', str[i].charCodeAt(), ';'].join(''));
}
return buf.join('');
};
str = encodeHTMLEntities(decodeHTMLEntities("#{email}").replace(/[!-~]/g,function(c){return String.fromCharCode(126>=(c=c.charCodeAt(0)+47)?c:c-94);}));
document.write("<" + "a h" + "ref=\\\"mai" + "lto:" + str + "\\\">" + str + "</" + "a>");
})()
</script>
<noscript><em>(Please enable JavaScript to show the email address)</em></noscript>
HTML
end
def og_type
if is_blog_article?

View File

@ -11,8 +11,7 @@ Frankfurter Allee 53<br>
10247 Berlin<br>
GERMANY
Website: <%= link_to blog_author.website.sub(%r{^https?://}, ''), blog_author.website %><br>
E-Mail: <a href="mailto:<%= blog_author.email %>"><%= blog_author.email %></a>
<p><%= author_email_link %></p>
Diese Daten dürfen nicht zu Werbezwecken genutzt werden.<br>
This data may not be used for advertising purposes.