use Illuminate\Http\Request;
use Illuminate\Http\Response;
-class EmailObfuscate extends CubistMiddleware
-{
- public function handle(Request $request, Closure $next)
- {
+class EmailObfuscate extends CubistMiddleware {
+ public function handle(Request $request, Closure $next) {
parent::handle($request, $next);
if ($this->onAdmin()) {
return $this->getResponse();
* @param $content
* @return mixed
*/
- public function obfuscate($content)
- {
+ public function obfuscate($content) {
$content = preg_replace_callback('/href="(mailto:)([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)/', [$this, '_replaceMailto'], $content);
+ $content = preg_replace_callback('/(\w+)="([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)/', [$this, '_replaceAttr'], $content);
$content = preg_replace_callback('/([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)/', [$this, '_replaceEmail'], $content);
return $content;
}
- protected function _replaceMailto($matches)
- {
+ protected function _replaceAttr($matches) {
+ return 'data-m-class="fdkt5" data-m-content="' . base64_encode($matches[1]) . ':' . base64_encode($matches[2] . "@" . $matches[3] . "." . $matches[4]) . "#hdfr";
+ }
+
+ protected function _replaceMailto($matches) {
return 'data-m-class="gfo45" data-m-content="a654d5:' . base64_encode($matches[2] . "@" . $matches[3] . "." . $matches[4]) . "#hdfr";
}
- protected function _replaceEmail($matches)
- {
+ protected function _replaceEmail($matches) {
return '<span data-m-class="8fr4g" data-m-content="56548df:' . base64_encode($matches[1] . "@" . $matches[2] . "." . $matches[3]) . '#fde4"></span>';
}
}
e.setAttribute('href', 'mailto:' + email);
});
+ // fdkt5
+ document.querySelectorAll('[data-m-class="fdkt5"]').forEach(function (e) {
+ var encoded = e.getAttribute('data-m-content');
+ var m = /^([a-zA-Z0-9\/\+=]*):([a-zA-Z0-9\/\+=]*)#hdfr$/i.exec(encoded);
+ if (null === m) {
+ return;
+ }
+ var email = atob(m[2]);
+ e.setAttribute(atob(m[1]), email);
+ });
+
+
document.querySelectorAll('[data-m-class="8fr4g"]').forEach(function (e) {
var encoded = e.getAttribute('data-m-content');
var m = /^56548df:([a-zA-Z0-9\/\+=]*)#fde4$/i.exec(encoded);