namespace wcf\system\email;
-use TrueBV\Exception\OutOfBoundsException;
-use TrueBV\Punycode;
+use GuzzleHttp\Psr7\Uri;
+use GuzzleHttp\Utils;
use wcf\data\language\Language;
use wcf\system\language\LanguageFactory;
+ use wcf\util\StringUtil;
/**
* Represents a RFC 5322 mailbox.
/**
* Creates a new Mailbox.
*
- * @param string $address email address of this mailbox
- * @param string $name human readable name of this mailbox (or null)
- * @param Language $language Language to use for localization (or null for the default language)
- * @throws \DomainException
+ * @param $address email address of this mailbox
+ * @param $name human readable name of this mailbox (or null)
+ * @param $language Language to use for localization (or null for the default language)
+ * @throws \DomainException
*/
- public function __construct($address, $name = null, ?Language $language = null)
+ public function __construct(string $address, ?string $name = null, ?Language $language = null)
{
$this->address = self::filterAddress($address);
- $this->name = $name;
+ $this->name = $name !== null ? StringUtil::trim($name) : null;
if ($language === null) {
$this->languageID = LanguageFactory::getInstance()->getDefaultLanguageID();
} else {
/**
* Returns a string representation for use in a RFC 5322 message.
- *
- * @return string
*/
- public function __toString()
+ public function __toString(): string
{
- if ($this->name === null || $this->name === $this->address) {
+ if (
+ $this->name === null
+ || $this->name === ''
+ || $this->name === $this->address
+ ) {
return $this->address;
}
// and it is supported by default in common JavaScript frameworks.
// 2) We want to set the SameSite=lax parameter.
// 3) We don't want the HttpOnly parameter.
- $sameSite = $cookieDomain = '';
- if (ApplicationHandler::getInstance()->isMultiDomainSetup()) {
- // We need to specify the cookieDomain in a multi domain set-up, because
- // otherwise no cookies are sent to subdomains.
- $cookieDomain = HeaderUtil::getCookieDomain();
- $cookieDomain = ($cookieDomain !== null ? '; domain=' . $cookieDomain : '');
- } else {
- // SameSite=lax is not supported in a multi domain set-up, because
- // it breaks cross-application requests.
- $sameSite = '; SameSite=lax';
+ $sameSite = '; SameSite=lax';
- // Workaround for WebKit Bug #255524.
- // https://bugs.webkit.org/show_bug.cgi?id=255524
- $sameSite = '';
- }
-
- if (!HTTP_SEND_X_FRAME_OPTIONS) {
- $sameSite = '; SameSite=none';
- }
++ // Workaround for WebKit Bug #255524.
++ // https://bugs.webkit.org/show_bug.cgi?id=255524
++ $sameSite = '';
+
\header(
- 'set-cookie: XSRF-TOKEN=' . \rawurlencode($xsrfToken) . '; path=/' . $cookieDomain . (RouteHandler::secureConnection() ? '; secure' : '') . $sameSite,
+ 'set-cookie: XSRF-TOKEN=' . \rawurlencode($xsrfToken) . '; path=/' . (RouteHandler::secureConnection() ? '; secure' : '') . $sameSite,
false
);
}