From: Tim Düsterhus Date: Tue, 19 Sep 2023 08:57:33 +0000 (+0200) Subject: Add Mailbox::getAddressForMailto() X-Git-Tag: 6.0.0_RC_2~35^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8ea9972cecc791eacf87ed9cefdc753dd481503c;p=GitHub%2FWoltLab%2FWCF.git Add Mailbox::getAddressForMailto() --- diff --git a/wcfsetup/install/files/lib/system/email/Mailbox.class.php b/wcfsetup/install/files/lib/system/email/Mailbox.class.php index af8e4f2bb4..1abf0acc15 100644 --- a/wcfsetup/install/files/lib/system/email/Mailbox.class.php +++ b/wcfsetup/install/files/lib/system/email/Mailbox.class.php @@ -133,6 +133,22 @@ class Mailbox return $this->address; } + /** + * Returns the properly encoded address for use within + * the 'mailto' URI scheme. + * + * This method takes care to encode the localpart and domain + * separately, leaving the '@' as-is. + * + * @since 6.0 + */ + public function getAddressForMailto(): string + { + [$localpart, $domain] = self::splitLocalpartAndDomain($this->getAddress()); + + return \rawurlencode($localpart) . '@' . \rawurlencode($domain); + } + /** * Returns the language the recipient of this mailbox wants. * This is used for localization of the email template.