#81939Allow right click and copy for spam protected email addresses
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
Related issues 2
History 67
-
Riccardo De Contardi changed category <span data-processor="relativetime" data-value="2020-03-24T22:24:29+00:00" > 03/24/20, 22:24 </span>
-
Riccardo De Contardi commented <span data-processor="relativetime" data-value="2020-04-13T18:26:35+00:00" > 04/13/20, 18:26 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 79068 status
NewUnder Review <span data-processor="relativetime" data-value="2023-05-18T16:12:47+00:00" > 05/18/23, 16:12 </span> -
Benni Mack changed Related to #101228 <span data-processor="relativetime" data-value="2023-07-05T08:50:57+00:00" > 07/05/23, 08:50 </span>
-
Riccardo De Contardi changed Related to #94904 <span data-processor="relativetime" data-value="2024-05-04T19:41:23+00:00" > 05/04/24, 19:41 </span>
-
Benni Mack changed status
Under ReviewNew <span data-processor="relativetime" data-value="2026-11-09T11:23:10+00:00" > 11/09/26, 11:23 </span> -
Georg Ringer commented and changed status
NewClosed <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 ashref="#"together withdata-mailto-tokenanddata-mailto-vectorattributes (seeEmailLinkBuilder), and the address is decrypted bydefault_frontend.json click. The code locations mentioned in the description (PageGenerator.phpand 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 thatconfig.spamProtectEmailAddressesprovides. 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_lastDotSubstoptions, 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.
- Decrypting the address on
As far as I have understood, this feature is covered by the third-party extensione emailobfuscator
https://extensions.typo3.org/extension/emailobfuscator