Issue Feature Closed

#81939Allow right click and copy for spam protected email addresses

Neil Haskins 07/21/17, 01:29 updated 11/14/26, 20:32

Description

Currently, if someone right clicks and copies a spam protected email address, they get javascript:linkTo_UnCryptMailto(‘sdfgserwhatevereteggh’);
For email where the link text is not the address, I could see those who don’t use an email client being unsure of how to get the address.

What I’ve experimented with is triggering a function on opening the context menu, to replace the href contents with the correct email.

Example here: https://jsfiddle.net/nhaskins/1nk7ky75/2/

I’ve tested this in TYPO3 by adding the following function to typo3/sysext/frontend/Classes/Page/PageGenerator.php at line 756 (end of $scriptJsCode)

function UnCryptMailto(el) {
    var str = el.getAttribute("href").split("\'")[1];
    el.setAttribute("href", decryptString(str,' . $tsfe->spamProtectEmailAddresses * -1 . '));
    el.removeAttribute("oncontextmenu");
}

and the following in typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php at line 5646 (just before $tagAttributes = [];)

if ($tsfe->spamProtectEmailAddresses) {
    $finalTagParts['aTagParams'] .= ' oncontextmenu="UnCryptMailto(this)"';
}

I’m pretty sure this isn’t the best way to include the oncontextmenu attribute, and it looks like it would need to be added to at least the f:link.email viewhelper as well.

Reviews 1

History 67

  1. Riccardo De Contardi commented <span data-processor="relativetime" data-value="2020-04-13T18:26:35+00:00" > 04/13/20, 18:26 </span>

    As far as I have understood, this feature is covered by the third-party extensione emailobfuscator

    https://extensions.typo3.org/extension/emailobfuscator

  2. Georg Ringer commented and changed status New Closed <span data-processor="relativetime" data-value="2026-11-14T20:32:29+00:00" > 11/14/26, 20:32 </span>

    Hi Neil, thanks for the report!

    Since this was filed, the implementation has changed. Spam protected email links no longer use a javascript:linkTo_UnCryptMailto(...) href. They are now rendered as href="#" together with data-mailto-token and data-mailto-vector attributes (see EmailLinkBuilder), and the address is decrypted by default_frontend.js on click. The code locations mentioned in the description (PageGenerator.php and the inline $scriptJsCode) do not exist anymore, so the proposed patch cannot be applied as it is.

    The underlying wish, being able to copy the real address via the context menu, is still not covered. I am closing this nevertheless, for these reasons:

    • Decrypting the address on contextmenu (or any other event a crawler can trigger) removes the very protection that config.spamProtectEmailAddresses provides. Bots which execute events or render the DOM would get the plain address.
    • In #94904 the decision was to keep the option as it is rather than to extend it.
    • Gerrit change 79068 was abandoned, and there has been no further demand or activity since 2017.

    Editors who need a copyable address can show the address as link text with the spamProtectEmailAddresses_atSubst / spamProtectEmailAddresses_lastDotSubst options, or use a third-party extension such as emailobfuscator.

    Thanks again for your work on this, and feel free to pick it up again if you are still interested.