From f88dcf4b14af14a98ad96b14b2b317969eab6715 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 18 Jun 2022 22:57:19 +0200 Subject: [PATCH] Don't use utf8_en/decode() functions, they're deprecated on PHP 8.2 (#325) --- src/EmailLexer.php | 2 +- src/Parser/DomainPart.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/EmailLexer.php b/src/EmailLexer.php index e7a96cc..7e660b6 100644 --- a/src/EmailLexer.php +++ b/src/EmailLexer.php @@ -237,7 +237,7 @@ protected function getType(&$value) $encoded = $value; if (mb_detect_encoding($value, 'auto', true) !== 'UTF-8') { - $encoded = utf8_encode($value); + $encoded = mb_convert_encoding($value, 'UTF-8', 'Windows-1252'); } if ($this->isValid($encoded)) { diff --git a/src/Parser/DomainPart.php b/src/Parser/DomainPart.php index 4ca54f2..f171740 100644 --- a/src/Parser/DomainPart.php +++ b/src/Parser/DomainPart.php @@ -292,7 +292,7 @@ private function checkLabelLength(bool $isEndOfDomain = false) : Result private function isLabelTooLong(string $label) : bool { if (preg_match('/[^\x00-\x7F]/', $label)) { - idn_to_ascii(utf8_decode($label), IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $idnaInfo); + idn_to_ascii($label, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $idnaInfo); return (bool) ($idnaInfo['errors'] & IDNA_ERROR_LABEL_TOO_LONG); } return strlen($label) > self::LABEL_MAX_LENGTH; @@ -309,4 +309,4 @@ public function domainPart() : string { return $this->domainPart; } -} \ No newline at end of file +}