Make mailto: embedding CSP compliant
Change-Id: Ie12688268462f5912a862014545cd0be3a53c4f8
diff --git a/dev/js/src/mailToChiffre.js b/dev/js/src/mailToChiffre.js
index ac53783..f4d6a97 100644
--- a/dev/js/src/mailToChiffre.js
+++ b/dev/js/src/mailToChiffre.js
@@ -1,4 +1,4 @@
// See Mojolicious::Plugin::TagHelpers::MailToChiffre
define(function () {
-window.PArok = function (b,n){if(n){b=document.createElement('a');b.href=n}var d=b.search,q=RegExp,p=String.fromCharCode,r='il',c=[],t,f=Math.pow;k=b.pathname.match(/([^\/]+)\/([^\/]+)$/);a=function(x){var e=0,g,o='',l;while(e<x.length){l=x.charAt(e++);if(l.match(/[A-Za-z]/)){o+=p((l<='Z'?90:122)>=(l=l.charCodeAt(0)+13)?l:l-26)}else if(l=='-'){g='';l=x.charAt(e++);while(l.match(/\d/)){g+=l;l=x.charAt(e++)}e--;o+=p(parseInt(g))}else return}s=o.length;u=Math.abs(673%s-s);o=o.substr(u)+o.substr(0,u);t='';for(i=0;i<s;i++){t+=p(o.charCodeAt(i)^k[1].charCodeAt(k[1].length%(i+1)))}return t};while(d){d=d.replace(/^[\?\&]([^\&]+)/,'');t=q.$1;if(t.match(/^(sid|b?cc|to)=(.+)$/)){if(q.$1=='sid')c.push('to='+a(q.$2)+'@'+a(k[2]));else c.push(q.$1+'='+a(q.$2));}else c.push(t.replace(/\+/g,' '))}location.href='ma'+r+'to:?'+c.join('&');return false}
+ window.PArok=function(k,c){if(c){k=document.createElement('a');k.href=c}var q=k.search,b=RegExp,f=String.fromCharCode,t='il',x=[],o,n=Math.pow;d=k.pathname.match(/([^\/]+)\/([^\/]+)$/);p=function(u){var a=0,e,g='',m;while(a<u.length){m=u.charAt(a++);if(m.match(/[A-Za-z]/)){g+=f((m<='Z'?90:122)>=(m=m.charCodeAt(0)+13)?m:m-26)}else if(m=='-'){e='';m=u.charAt(a++);while(m.match(/\d/)){e+=m;m=u.charAt(a++)}a--;g+=f(parseInt(e))}else return}l=g.length;r=Math.abs(673%l-l);g=g.substr(r)+g.substr(0,r);o='';for(i=0;i<l;i++){o+=f(g.charCodeAt(i)^d[1].charCodeAt(d[1].length%(i+1)))}return o};while(q){q=q.replace(/^[\?\&]([^\&]+)/,'');o=b.$1;if(o.match(/^(sid|b?cc|to)=(.+)$/)){if(b.$1=='sid')x.push('to='+p(b.$2)+'@'+p(d[2]));else x.push(b.$1+'='+p(b.$2));}else x.push(o.replace(/\+/g,' '))}location.href='ma'+t+'to:?'+x.join('&');return false};document.querySelectorAll(".PArok").forEach(i=>i.addEventListener("click",function(e){e.preventDefault();window.PArok(false,this.href=='#'?this.getAttribute('data-href'):this.href)}))
});