#103861email addresses with special characters breaks email substitution
Description
When a email address with special characters is fed to \TYPO3\CMS\Frontend\Typolink\EmailLinkBuilder::processEmailLink(), the replacement won’t work properly, due to a string mismatch.
TypoScript setup to reproduce:
config {
spamProtectEmailAddresses = 4
spamProtectEmailAddresses_atSubst = (at)
spamProtectEmailAddresses_lastDotSubst = (dot)
}
page = PAGE
page {
100 = TEXT
100 {
typolink.parameter = nomail@domain.com
wrap = |<br>
}
200 = TEXT
200 {
typolink.parameter = no'mail@domain.com
wrap = |<br>
}
}
Expected Output:
<a href="#" data-mailto-token="qempxs.rs2qempDhsqemr2gsq" data-mailto-vector="4">no.mail(at)domain(dot)com</a><br>
<a href="#" data-mailto-token="qempxs.rs'qempDhsqemr2gsq" data-mailto-vector="4">no'mail@domain.com</a><br>
Actual Output:
<a href="#" data-mailto-token="qempxs.rs2qempDhsqemr2gsq" data-mailto-vector="4">no.mail(at)domain(dot)com</a><br>
<a href="#" data-mailto-token="qempxs.rs'qempDhsqemr2gsq" data-mailto-vector="4">no'mail(at)domain(dot)com</a><br>
My purposed solution is, to use htmlspecialchars when ultimately replacing $mailAddress of $linkText.
P.S.: Yeah I had to look it up, if/which special characters are even allowed in email addresses. The following post summarizes them quite good:
https://stackoverflow.com/a/2049510
Reviews 2
History 310
-
Gerrit Code Review pushed patch set 1 for main to change 84316 status
NewUnder Review <span data-processor="relativetime" data-value="2024-05-20T09:47:23+00:00" > 05/20/24, 09:47 </span> -
Gerrit Code Review pushed patch set 2 for main to change 84316 <span data-processor="relativetime" data-value="2024-10-18T13:30:43+00:00" > 10/18/24, 13:30 </span>
-
Gerrit Code Review pushed patch set 3 for main to change 84316 <span data-processor="relativetime" data-value="2025-03-26T21:30:07+00:00" > 03/26/25, 21:30 </span>
-
Gerrit Code Review pushed patch set 4 for main to change 84316 <span data-processor="relativetime" data-value="2025-03-27T21:19:47+00:00" > 03/27/25, 21:19 </span>
-
Gerrit Code Review pushed patch set 5 for main to change 84316 <span data-processor="relativetime" data-value="2025-03-27T21:35:14+00:00" > 03/27/25, 21:35 </span>
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 88814 <span data-processor="relativetime" data-value="2025-03-27T21:51:30+00:00" > 03/27/25, 21:51 </span>
-
Gerrit Code Review pushed patch set 2 for 13.4 to change 88814 <span data-processor="relativetime" data-value="2025-03-27T21:57:42+00:00" > 03/27/25, 21:57 </span>
-
Moritz Ngo commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2025-03-27T22:00:09+00:00" > 03/27/25, 22:00 </span>Applied in changeset commit:48298851b8a46a1f1410811527cc8eec83d6bece.
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2025-12-02T14:33:23+00:00" > 12/02/25, 14:33 </span>
To summarize RFC 5322:
You can put nearly anything into the
local-partof an e-mail address as long as its double-quoted in the “Internet Message Format”.So
".have-fun'"example.org@ is a valid e-mail address…See https://www.rfc-editor.org/rfc/rfc5322
addr-spec = local-part "@" domain local-part = dot-atom / quoted-string / obs-local-part quoted-string = [CFWS] DQUOTE *([FWS] qcontent) [FWS] DQUOTE [CFWS] ---- qcontent = qtext / quoted-pair qtext = %d33 / ; Printable US-ASCII %d35-91 / ; characters not including %d93-126 / ; "\" or the quote character obs-qtext obs-qtext = obs-NO-WS-CTL obs-NO-WS-CTL = %d1-8 / ; US-ASCII control %d11 / ; characters that do not %d12 / ; include the carriage %d14-31 / ; return, line feed, and %d127 ; white space charactersExceptions:
– These characters may still appear, but ‘are semantically “invisible”’. –
> Semantically, neither the optional CFWS outside of the quote
> characters nor the quote characters themselves are part of the
> quoted-string; the quoted-string is what is contained between the two
> quote characters. As stated earlier, the “\” in any quoted-pair and
> the CRLF in any FWS/CFWS that appears within the quoted-string are
> semantically “invisible” and therefore not part of the quoted-string
> either.