Файловый менеджер - Редактировать - /var/www/html/algo26-matthias.zip
Ðазад
PK ! �W�� � ( idna-convert/src/AbstractIdnaConvert.phpnu �[��� <?php namespace Algo26\IdnaConvert; use InvalidArgumentException; abstract class AbstractIdnaConvert { abstract public function convert(string $host): string; /** * @param string $emailAddress * * @return string */ public function convertEmailAddress(string $emailAddress): string { if (strpos($emailAddress, '@') === false) { throw new InvalidArgumentException('The given string does not look like an email address', 206); } $parts = explode('@', $emailAddress); return sprintf( '%s@%s', $parts[0], $this->convert($parts[1]) ); } /** * @param string $url * * @return string */ public function convertUrl(string $url): string { $parsed = parse_url($url); if ($parsed === false) { throw new InvalidArgumentException('The given string does not look like a URL', 206); } // Nothing to do if (!isset($parsed['host']) || $parsed['host'] === null) { return $url; } $parsed['host'] = $this->convert($parsed['host']); return http_build_url($parsed); } } PK ! rZ� ? idna-convert/src/TranscodeUnicode/TranscodeUnicodeInterface.phpnu �[��� <?php namespace Algo26\IdnaConvert\TranscodeUnicode; interface TranscodeUnicodeInterface { public function convert( $data, string $fromEncoding, string $toEncoding, bool $safeMode = false, int $safeCodepoint = 0xFFFC ); } PK ! ����6 �6 6 idna-convert/src/TranscodeUnicode/TranscodeUnicode.phpnu �[��� <?php /** * Converts between various flavours of Unicode representations like UCS-4 or UTF-8 * Supported schemes: * - UCS-4 Little Endian / Big Endian / Array (partially) * - UTF-16 Little Endian / Big Endian (not yet) * - UTF-8 * - UTF-7 * - UTF-7 IMAP (modified UTF-7) * * @package IdnaConvert * @author Matthias Sommerfeld <matthias.sommerfeld@algo26.de> * @copyright 2003-2019 algo26 Beratungs GmbH, Berlin, https://www.algo26.de */ namespace Algo26\IdnaConvert\TranscodeUnicode; use Algo26\IdnaConvert\Exception\InvalidCharacterException; use InvalidArgumentException; class TranscodeUnicode implements TranscodeUnicodeInterface { public const FORMAT_UCS4 = 'ucs4'; public const FORMAT_UCS4_ARRAY = 'ucs4array'; public const FORMAT_UTF8 = 'utf8'; public const FORMAT_UTF7 = 'utf7'; public const FORMAT_UTF7_IMAP = 'utf7imap'; private const encodings = [ self::FORMAT_UCS4, self::FORMAT_UCS4_ARRAY, self::FORMAT_UTF8, self::FORMAT_UTF7, self::FORMAT_UTF7_IMAP ]; private $safeMode; private $safeCodepoint = 0xFFFC; public function convert( $data, string $fromEncoding, string $toEncoding, bool $safeMode = false, ?int $safeCodepoint = null ) { $this->safeMode = $safeMode; if ($safeCodepoint !== null) { $this->safeCodepoint = $safeCodepoint; } $fromEncoding = strtolower($fromEncoding); $toEncoding = strtolower($toEncoding); if ($fromEncoding === $toEncoding) { return $data; } if (!in_array($fromEncoding, self::encodings)) { throw new InvalidArgumentException(sprintf('Invalid input format %s', $fromEncoding), 300); } if (!in_array($toEncoding, self::encodings)) { throw new InvalidArgumentException(sprintf('Invalid output format %s', $toEncoding), 301); } if ($fromEncoding !== self::FORMAT_UCS4_ARRAY) { $methodName = sprintf('%s_%s', $fromEncoding, self::FORMAT_UCS4_ARRAY); $data = $this->$methodName($data); } if ($toEncoding !== self::FORMAT_UCS4_ARRAY) { $methodName = sprintf('%s_%s', self::FORMAT_UCS4_ARRAY, $toEncoding); $data = $this->$methodName($data); } return $data; } /** * This converts an UTF-8 encoded string to its UCS-4 representation * * @param string $input The UTF-8 string to convert * * @return array Array of 32bit values representing each codepoint * @throws InvalidCharacterException * @access public */ private function utf8_ucs4array($input) { $startByte = 0; $nextByte = 0; $output = []; $outputLength = 0; $inputLength = $this->byteLength($input); $mode = 'next'; $test = 'none'; for ($k = 0; $k < $inputLength; ++$k) { $v = ord($input[$k]); // Extract byte from input string if ($v < 128) { // We found an ASCII char - put into string as is $output[$outputLength] = $v; ++$outputLength; if ('add' === $mode) { if ($this->safeMode) { $output[$outputLength - 2] = $this->safeCodepoint; $mode = 'next'; } else { throw new InvalidCharacterException( sprintf( 'Conversion from UTF-8 to UCS-4 failed: malformed input at byte %d', $k ), 302 ); } } continue; } if ('next' === $mode) { // Try to find the next start byte; determine the width of the Unicode char $startByte = $v; $mode = 'add'; $test = 'range'; if ($v >> 5 === 6) { // &110xxxxx 10xxxxx $nextByte = 0; // How many times subsequent bit masks must rotate 6bits to the left $v = ($v - 192) << 6; } elseif ($v >> 4 === 14) { // &1110xxxx 10xxxxxx 10xxxxxx $nextByte = 1; $v = ($v - 224) << 12; } elseif ($v >> 3 === 30) { // &11110xxx 10xxxxxx 10xxxxxx 10xxxxxx $nextByte = 2; $v = ($v - 240) << 18; } elseif ($this->safeMode) { $mode = 'next'; $output[$outputLength] = $this->safeCodepoint; ++$outputLength; continue; } else { throw new InvalidCharacterException( sprintf('This might be UTF-8, but I don\'t understand it at byte %d', $k), 303 ); } if (($inputLength - $k - $nextByte) < 2) { $output[$outputLength] = $this->safeCodepoint; $mode = 'no'; continue; } if ('add' === $mode) { $output[$outputLength] = (int)$v; ++$outputLength; continue; } } if ('add' == $mode) { if (!$this->safeMode && $test === 'range') { $test = 'none'; if (($v < 0xA0 && $startByte === 0xE0) || ($v < 0x90 && $startByte === 0xF0) || ($v > 0x8F && $startByte === 0xF4) ) { throw new InvalidCharacterException( sprintf('Bogus UTF-8 character (out of legal range) at byte %d', $k), 304 ); } } if ($v >> 6 === 2) { // Bit mask must be 10xxxxxx $v = ($v - 128) << ($nextByte * 6); $output[($outputLength - 1)] += $v; --$nextByte; } else { if ($this->safeMode) { $output[$outputLength - 1] = ord($this->safeCodepoint); $k--; $mode = 'next'; continue; } else { throw new InvalidCharacterException( sprintf('Conversion from UTF-8 to UCS-4 failed: malformed input at byte %d', $k), 302 ); } } if ($nextByte < 0) { $mode = 'next'; } } } // for return $output; } /** * Convert UCS-4 arary into UTF-8 string * See utf8_ucs4array() for details * * @param $input array Array of UCS-4 codepoints * * @return string * @access public * @throws InvalidCharacterException */ private function ucs4array_utf8($input) { $output = ''; foreach ($input as $k => $v) { if ($v < 128) { // 7bit are transferred literally $output .= chr($v); } elseif ($v < (1 << 11)) { // 2 bytes $output .= sprintf( '%s%s', chr(192 + ($v >> 6)), chr(128 + ($v & 63)) ); } elseif ($v < (1 << 16)) { // 3 bytes $output .= sprintf( '%s%s%s', chr(224 + ($v >> 12)), chr(128 + (($v >> 6) & 63)), chr(128 + ($v & 63)) ); } elseif ($v < (1 << 21)) { // 4 bytes $output .= sprintf( '%s%s%s%s', chr(240 + ($v >> 18)), chr(128 + (($v >> 12) & 63)), chr(128 + (($v >> 6) & 63)), chr(128 + ($v & 63)) ); } elseif ($this->safeMode) { $output .= $this->safeCodepoint; } else { throw new InvalidCharacterException( sprintf('Conversion from UCS-4 to UTF-8 failed: malformed input at byte %d', $k), 305 ); } } return $output; } private function utf7imap_ucs4array($input) { return $this->utf7_ucs4array(str_replace(',', '/', $input), '&'); } private function utf7_ucs4array($input, $sc = '+') { $output = []; $outputLength = 0; $inputLength = $this->byteLength($input); $mode = 'd'; $b64 = ''; for ($k = 0; $k < $inputLength; ++$k) { $c = $input[$k]; // Ignore zero bytes if (0 === ord($c)) { continue; } if ('b' === $mode) { // Sequence got terminated if (!preg_match('![A-Za-z0-9/'.preg_quote($sc, '!').']!', $c)) { if ('-' == $c) { if ($b64 === '') { $output[$outputLength] = ord($sc); $outputLength++; $mode = 'd'; continue; } } $tmp = base64_decode($b64); $tmp = substr($tmp, -1 * (strlen($tmp) % 2)); for ($i = 0; $i < strlen($tmp); $i++) { if ($i % 2) { $output[$outputLength] += ord($tmp[$i]); $outputLength++; } else { $output[$outputLength] = ord($tmp[$i]) << 8; } } $mode = 'd'; $b64 = ''; continue; } else { $b64 .= $c; } } if ('d' === $mode) { if ($sc === $c) { $mode = 'b'; continue; } $output[$outputLength] = ord($c); $outputLength++; } } return $output; } private function ucs4array_utf7imap($input) { return str_replace( '/', ',', $this->ucs4array_utf7($input, '&') ); } private function ucs4array_utf7($input, $sc = '+') { $output = ''; $mode = 'd'; $b64 = ''; while (true) { $v = (!empty($input)) ? array_shift($input) : false; $isDirect = (false !== $v) ? (0x20 <= $v && $v <= 0x7e && $v !== ord($sc)) : true; if ($mode === 'b') { if ($isDirect) { if ($b64 === chr(0).$sc) { $output .= $sc.'-'; $b64 = ''; } elseif ($b64) { $output .= $sc.str_replace('=', '', base64_encode($b64)).'-'; $b64 = ''; } $mode = 'd'; } elseif (false !== $v) { $b64 .= chr(($v >> 8) & 255).chr($v & 255); } } if ($mode === 'd' && false !== $v) { if ($isDirect) { $output .= chr($v); } else { $b64 = chr(($v >> 8) & 255).chr($v & 255); $mode = 'b'; } } if (false === $v && $b64 === '') { break; } } return $output; } /** * Convert UCS-4 array into UCS-4 string (Little Endian at the moment) * @param $input array UCS-4 code points * @return string * @access public */ private function ucs4array_ucs4($input) { $output = ''; foreach ($input as $v) { $output .= sprintf( '%s%s%s%s', chr(($v >> 24) & 255), chr(($v >> 16) & 255), chr(($v >> 8) & 255), chr($v & 255) ); } return $output; } /** * Convert UCS-4 string (LE ar the moment) into UCS-4 array * * @param $input string UCS-4 LE string * * @return array * @access public * @throws InvalidCharacterException */ private function ucs4_ucs4array($input) { $output = []; $inputLength = $this->byteLength($input); // Input length must be dividable by 4 if ($inputLength % 4) { throw new InvalidCharacterException('Input UCS4 string is broken', 306); } // Empty input - return empty output if (!$inputLength) { return $output; } for ($i = 0, $outputLength = -1; $i < $inputLength; ++$i) { if (!($i % 4)) { // Increment output position every 4 input bytes $outputLength++; $output[$outputLength] = 0; } $output[$outputLength] += ord($input[$i]) << (8 * (3 - ($i % 4))); } return $output; } /** * Gets the length of a string in bytes even if mbstring function * overloading is turned on * * @param string $string the string for which to get the length. * @return integer the length of the string in bytes. */ protected function byteLength($string) { if ((extension_loaded('mbstring') && (ini_get('mbstring.func_overload') & 0x02) === 0x02) ) { return mb_strlen($string, '8bit'); } return strlen((string) $string); } } PK ! �^�� � ; idna-convert/src/EncodingHelper/EncodingHelperInterface.phpnu �[��� <?php namespace Algo26\IdnaConvert\EncodingHelper; interface EncodingHelperInterface { public function convert( string $sourceString, string $encoding = 'ISO-8859-1', bool $safeMode = false ); } PK ! ��{� � * idna-convert/src/EncodingHelper/ToUtf8.phpnu �[��� <?php namespace Algo26\IdnaConvert\EncodingHelper; class ToUtf8 implements EncodingHelperInterface { private const DEFAULT_ENCODING = 'ISO-8859-1'; private $encoding = self::DEFAULT_ENCODING; public function convert( string $sourceString, ?string $encoding = self::DEFAULT_ENCODING, ?bool $safeMode = false ) { $safe = ($safeMode) ? $sourceString : false; if ($encoding !== null) { $this->encoding = strtoupper($encoding); } else { $this->encoding = 'ISO-8859-1'; } if ($this->encoding === 'UTF-8' || $this->encoding === 'UTF8') { return $sourceString; } if ($this->encoding === 'ISO-8859-1') { return utf8_encode($sourceString); } if ($this->encoding === 'WINDOWS-1252') { return utf8_encode($this->mapWindows1252ToIso8859_1($sourceString)); } if ($this->encoding === 'UNICODE-1-1-UTF-7') { $this->encoding = 'UTF-7'; } $converted = $this->convertWithLibraries($sourceString); if (false !== $converted) { return $converted; } return $safe; } /** * Special treatment for our guys in Redmond * Windows-1252 is basically ISO-8859-1 -- with some exceptions, which get dealt with here * * @param string $string Your input in Win1252 * * @return string The resulting ISO-8859-1 string * @since 0.0.1 */ private function mapWindows1252ToIso8859_1($string = '') { $return = ''; for ($i = 0; $i < strlen($string); ++$i) { $codePoint = ord($string[$i]); switch ($codePoint) { case 129: $return .= chr(252); break; case 132: $return .= chr(228); break; case 142: $return .= chr(196); break; case 148: $return .= chr(246); break; case 153: $return .= chr(214); break; case 154: $return .= chr(220); break; case 225: $return .= chr(223); break; default: $return .= chr($codePoint); } } return $return; } private function convertWithLibraries(string $string): ?string { if (function_exists('mb_convert_encoding')) { $converted = @mb_convert_encoding($string, 'UTF-8', $this->encoding); if (false !== $converted) { return $converted; } } if (function_exists('iconv')) { $converted = @iconv($this->encoding, 'UTF-8', $string); if (false !== $converted) { return $converted; } } if (function_exists('libiconv')) { $converted = @libiconv($this->encoding, 'UTF-8', $string); if (false !== $converted) { return $converted; } } return false; } } PK ! ���� � , idna-convert/src/EncodingHelper/FromUtf8.phpnu �[��� <?php namespace Algo26\IdnaConvert\EncodingHelper; class FromUtf8 implements EncodingHelperInterface { private const DEFAULT_ENCODING = 'ISO-8859-1'; private $encoding = self::DEFAULT_ENCODING; public function convert( string $sourceString, ?string $encoding = self::DEFAULT_ENCODING, ?bool $safeMode = false ) { $safe = ($safeMode) ? $sourceString : false; if ($encoding !== null) { $this->encoding = strtoupper($encoding); } else { $this->encoding = 'ISO-8859-1'; } if ($this->encoding === 'UTF-8' || $this->encoding === 'UTF8') { return $sourceString; } if ($this->encoding === 'ISO-8859-1') { return utf8_decode($sourceString); } if ($this->encoding === 'WINDOWS-1252') { return self::mapIso8859_1ToWindows1252(utf8_decode($sourceString)); } if ($this->encoding === 'UNICODE-1-1-UTF-7') { $this->encoding = 'UTF-7'; } $converted = $this->convertWithLibraries($sourceString); if (false !== $converted) { return $converted; } return $safe; } /** * Special treatment for our guys in Redmond * Windows-1252 is basically ISO-8859-1 -- with some exceptions, which get dealt with here * * @param string $string Your input in ISO-8859-1 * * @return string The resulting Win1252 string * @since 0.0.1 */ private function mapIso8859_1ToWindows1252($string = '') { $return = ''; for ($i = 0; $i < strlen($string); ++$i) { $codePoint = ord($string[$i]); switch ($codePoint) { case 196: $return .= chr(142); break; case 214: $return .= chr(153); break; case 220: $return .= chr(154); break; case 223: $return .= chr(225); break; case 228: $return .= chr(132); break; case 246: $return .= chr(148); break; case 252: $return .= chr(129); break; default: $return .= chr($codePoint); } } return $return; } private function convertWithLibraries(string $string): ?string { if (function_exists('mb_convert_encoding')) { $converted = @mb_convert_encoding($string, $this->encoding, 'UTF-8'); if (false !== $converted) { return $converted; } } if (function_exists('iconv')) { $converted = @iconv('UTF-8', $this->encoding, $string); if (false !== $converted) { return $converted; } } if (function_exists('libiconv')) { $converted = @libiconv('UTF-8', $this->encoding, $string); if (false !== $converted) { return $converted; } } return false; } } PK ! %�w w 8 idna-convert/src/Exception/InvalidCharacterException.phpnu �[��� <?php namespace Algo26\IdnaConvert\Exception; use Exception; class InvalidCharacterException extends Exception { } PK ! ���x x 9 idna-convert/src/Exception/InvalidIdnVersionException.phpnu �[��� <?php namespace Algo26\IdnaConvert\Exception; use Exception; class InvalidIdnVersionException extends Exception { } PK ! '-tv v 7 idna-convert/src/Exception/AlreadyPunycodeException.phpnu �[��� <?php namespace Algo26\IdnaConvert\Exception; use Exception; class AlreadyPunycodeException extends Exception { } PK ! a�c� � idna-convert/src/ToIdn.phpnu �[��� <?php namespace Algo26\IdnaConvert; use Algo26\IdnaConvert\Exception\InvalidCharacterException; use Algo26\IdnaConvert\Exception\InvalidIdnVersionException; use Algo26\IdnaConvert\Punycode\ToPunycode; use Algo26\IdnaConvert\TranscodeUnicode\TranscodeUnicode; class ToIdn extends AbstractIdnaConvert implements IdnaConvertInterface { /** @var TranscodeUnicode */ private $unicodeTransCoder; /** @var ToPunycode */ private $punycodeEncoder; /** * @throws InvalidIdnVersionException */ public function __construct($idnVersion = null) { $this->unicodeTransCoder = new TranscodeUnicode(); $this->punycodeEncoder = new ToPunycode($idnVersion); } /** * @param string $host * * @return string * @throws InvalidCharacterException * @throws Exception\AlreadyPunycodeException */ public function convert(string $host): string { if (strlen($host) === 0) { return $host; } if (strpos('/', $host) !== false || strpos(':', $host) !== false || strpos('?', $host) !== false || strpos('@', $host) !== false ) { throw new InvalidCharacterException('Neither email addresses nor URLs are allowed', 205); } // These three punctuation characters are treated like the dot $host = str_replace(['。', '.', '。'], '.', $host); // Operate per label $hostLabels = explode('.', $host); foreach ($hostLabels as $index => $label) { $asUcs4Array = $this->unicodeTransCoder->convert( $label, $this->unicodeTransCoder::FORMAT_UTF8, $this->unicodeTransCoder::FORMAT_UCS4_ARRAY ); $encoded = $this->punycodeEncoder->convert($asUcs4Array); if ($encoded) { $hostLabels[$index] = $encoded; } } return implode('.', $hostLabels); } } PK ! X�gde e ( idna-convert/src/Punycode/ToPunycode.phpnu �[��� <?php namespace Algo26\IdnaConvert\Punycode; use Algo26\IdnaConvert\Exception\AlreadyPunycodeException; use Algo26\IdnaConvert\Exception\InvalidCharacterException; use Algo26\IdnaConvert\Exception\InvalidIdnVersionException; use Algo26\IdnaConvert\NamePrep\NamePrep; class ToPunycode extends AbstractPunycode implements PunycodeInterface { /** @var NamePrep */ private $namePrep; /** * @throws InvalidIdnVersionException */ public function __construct(?string $idnVersion = null) { $this->namePrep = new NamePrep($idnVersion); parent::__construct(); } /** * @param array $decoded * * @return string * @throws AlreadyPunycodeException * @throws InvalidCharacterException */ public function convert(array $decoded): string { // We cannot encode a domain name containing the Punycode prefix $checkForPrefix = array_slice($decoded, 0, self::$prefixLength); if (self::$prefixAsArray === $checkForPrefix) { throw new AlreadyPunycodeException('This is already a Punycode string', 100); } // We will not try to encode strings consisting of basic code points only $canEncode = false; foreach ($decoded as $k => $v) { if ($v > 0x7a) { $canEncode = true; break; } } if (!$canEncode) { return false; } // Do NAMEPREP $decoded = $this->namePrep->do($decoded); if (!$decoded || !is_array($decoded)) { return false; // NAMEPREP failed } $decodedLength = count($decoded); if (!$decodedLength) { return false; // Empty array } $codeCount = 0; // How many chars have been consumed $encoded = ''; // Copy all basic code points to output for ($i = 0; $i < $decodedLength; ++$i) { $test = $decoded[$i]; if (0x01 <= $test && $test <= 0x7f) { $encoded .= chr($decoded[$i]); $codeCount++; } } if ($codeCount === $decodedLength) { return $encoded; // All codepoints were basic ones } // Start with the prefix; copy it to output $encoded = self::punycodePrefix . $encoded; // If we have basic code points in output, add a hyphen to the end if ($codeCount > 0) { $encoded .= '-'; } // Now find and encode all non-basic code points $isFirst = true; $currentCode = self::initialN; $bias = self::initialBias; $delta = 0; while ($codeCount < $decodedLength) { $nextCode = self::maxUcs; // Find the next largest code point to $currentCode foreach ($decoded as $nextLargestCandidate) { if ($nextLargestCandidate >= $currentCode && $nextLargestCandidate <= $nextCode) { $nextCode = $nextLargestCandidate; } } $codeCountPlusOne = $codeCount + 1; $delta += ($nextCode - $currentCode) * $codeCountPlusOne; $currentCode = $nextCode; // Scan input again and encode all characters whose code point is $currentCode for ($i = 0; $i < $decodedLength; $i++) { if ($decoded[$i] < $currentCode) { $delta++; } if ($decoded[$i] === $currentCode) { for ($q = $delta, $k = self::base; 1; $k += self::base) { $t = ($k <= $bias) ? self::tMin : (($k >= $bias + self::tMax) ? self::tMax : $k - $bias ); if ($q < $t) { break; } $encoded .= $this->encodeDigit(intval($t + (($q - $t) % (self::base - $t)))); $q = (int) (($q - $t) / (self::base - $t)); } $encoded .= $this->encodeDigit($q); $bias = $this->adapt($delta, $codeCountPlusOne, $isFirst); $codeCount++; $delta = 0; $isFirst = false; } } $delta++; $currentCode++; } return $encoded; } /** * Encoding a certain digit * @param int $d * @return string */ private function encodeDigit($d): string { return chr($d + 22 + 75 * ($d < 26)); } } PK ! ����g g * idna-convert/src/Punycode/FromPunycode.phpnu �[��� <?php namespace Algo26\IdnaConvert\Punycode; use Algo26\IdnaConvert\Exception\InvalidCharacterException; use OutOfBoundsException; class FromPunycode extends AbstractPunycode implements PunycodeInterface { public function __construct(?string $idnVersion = null) { parent::__construct(); } /** * The actual decoding algorithm * * @param string * * @return mixed * @throws InvalidCharacterException */ public function convert($encoded) { if (!$this->validate($encoded)) { return false; } $decoded = []; // Find last occurrence of the delimiter $delimiterPosition = strrpos($encoded, '-'); if ($delimiterPosition > self::byteLength(self::punycodePrefix)) { for ($k = $this->byteLength(self::punycodePrefix); $k < $delimiterPosition; ++$k) { $decoded[] = ord($encoded[$k]); } } $decodedLength = count($decoded); $encodedLength = $this->byteLength($encoded); // Walking through the strings; init $isFirst = true; $bias = self::initialBias; $currentIndex = 0; $char = self::initialN; $startOfLoop = ($delimiterPosition) ? ($delimiterPosition + 1) : 0; for ($encodedIndex = $startOfLoop; $encodedIndex < $encodedLength; ++$decodedLength) { for ($oldIndex = $currentIndex, $w = 1, $k = self::base; 1; $k += self::base) { if ($encodedIndex + 1 > $encodedLength) { throw new InvalidCharacterException('trying to read beyond input length'); } $digit = $this->decodeDigit($encoded[$encodedIndex++]); if ($digit >= self::base) { throw new InvalidCharacterException( sprintf( 'encountered invalid digit at #%d', $encodedIndex - 1 ) ); } if ($digit > floor((PHP_INT_MAX - $currentIndex) / $w)) { throw new OutOfBoundsException( sprintf( 'overflow at #%d', $encodedIndex - 1 ) ); } $currentIndex += $digit * $w; $t = ($k <= $bias) ? self::tMin : ( ($k >= $bias + self::tMax) ? self::tMax : ($k - $bias) ); if ($digit < $t) { break; } $w = (int) ($w * (self::base - $t)); } $bias = $this->adapt($currentIndex - $oldIndex, $decodedLength + 1, $isFirst); $isFirst = false; $char += (int) ($currentIndex / ($decodedLength + 1)); $currentIndex %= ($decodedLength + 1); if ($decodedLength > 0) { // Make room for the decoded char for ($i = $decodedLength; $i > $currentIndex; $i--) { $decoded[$i] = $decoded[($i - 1)]; } } $decoded[$currentIndex++] = $char; } return $this->unicodeTransCoder->convert( $decoded, $this->unicodeTransCoder::FORMAT_UCS4_ARRAY, $this->unicodeTransCoder::FORMAT_UTF8 ); } /** * Checks, whether the provided string is a valid punycode string * @param string $encoded * @return boolean */ private function validate($encoded): bool { // Check for existence of the prefix if (strpos($encoded, self::punycodePrefix) !== 0) { return false; } // If nothing is left after the prefix, it is hopeless if (strlen(trim($encoded)) <= strlen(self::punycodePrefix)) { return false; } return true; } private function decodeDigit(string $codePoint): int { $codeAsInt = ord($codePoint); if ($codeAsInt - 48 < 10) { return $codeAsInt - 22; } if ($codeAsInt - 65 < 26) { return $codeAsInt - 65; } if ($codeAsInt - 97 < 26) { return $codeAsInt - 97; } return self::base; } } PK ! ���)� � . idna-convert/src/Punycode/AbstractPunycode.phpnu �[��� <?php namespace Algo26\IdnaConvert\Punycode; use Algo26\IdnaConvert\TranscodeUnicode\TranscodeUnicode; abstract class AbstractPunycode { const punycodePrefix = 'xn--'; const invalidUcs = 0x80000000; const maxUcs = 0x10FFFF; const base = 36; const tMin = 1; const tMax = 26; const skew = 38; const damp = 700; const initialBias = 72; const initialN = 0x80; protected static $isMbStringOverload; protected static $prefixAsArray; protected static $prefixLength; /** @var TranscodeUnicode */ protected $unicodeTransCoder; public function __construct() { $this->unicodeTransCoder = new TranscodeUnicode(); // populate mbstring overloading cache if not set if (self::$isMbStringOverload === null) { self::$isMbStringOverload = (extension_loaded('mbstring') && (ini_get('mbstring.func_overload') & 0x02) === 0x02); } if (self::$prefixAsArray === null) { self::$prefixAsArray = $this->unicodeTransCoder->convert( self::punycodePrefix, $this->unicodeTransCoder::FORMAT_UTF8, $this->unicodeTransCoder::FORMAT_UCS4_ARRAY ); self::$prefixLength = $this->byteLength(self::punycodePrefix); } } public function getPunycodePrefix(): string { return self::punycodePrefix; } /** * Gets the length of a string in bytes even if mbstring function * overloading is turned on * * @param string $string the string for which to get the length. * @return integer the length of the string in bytes. */ protected function byteLength($string): int { if (self::$isMbStringOverload) { return mb_strlen($string, '8bit'); } return strlen((string) $string); } /** * Adapt the bias according to the current code point and position * @param int $delta * @param int $nPoints * @param int $isFirst * @return int */ protected function adapt($delta, $nPoints, $isFirst): int { $delta = intval($isFirst ? ($delta / self::damp) : ($delta / 2)); $delta += intval($delta / $nPoints); for ($k = 0; $delta > ((self::base - self::tMin) * self::tMax) / 2; $k += self::base) { $delta = intval($delta / (self::base - self::tMin)); } return intval($k + (self::base - self::tMin + 1) * $delta / ($delta + self::skew)); } } PK ! �!Bg� � / idna-convert/src/Punycode/PunycodeInterface.phpnu �[��� <?php namespace Algo26\IdnaConvert\Punycode; interface PunycodeInterface { public function __construct(?string $idnVersion = null); public function getPunycodePrefix(); } PK ! ����� � idna-convert/src/ToUnicode.phpnu �[��� <?php namespace Algo26\IdnaConvert; use Algo26\IdnaConvert\Punycode\FromPunycode; use Algo26\IdnaConvert\TranscodeUnicode\TranscodeUnicode; class ToUnicode extends AbstractIdnaConvert implements IdnaConvertInterface { /** @var TranscodeUnicode */ private $unicodeTransCoder; /** @var FromPunycode */ private $punycodeEncoder; public function __construct() { $this->unicodeTransCoder = new TranscodeUnicode(); $this->punycodeEncoder = new FromPunycode(); } public function convert(string $host): string { // Drop any whitespace around $input = trim($host); $hostLabels = explode('.', $input); foreach ($hostLabels as $index => $label) { $return = $this->punycodeEncoder->convert($label); if (!$return) { $return = $label; } $hostLabels[$index] = $return; } return implode('.', $hostLabels); } } PK ! ��O� � ) idna-convert/src/IdnaConvertInterface.phpnu �[��� <?php namespace Algo26\IdnaConvert; interface IdnaConvertInterface { public function convert(string $host): string; public function convertEmailAddress(string $emailAddress): string; public function convertUrl(string $url): string; } PK ! �U6� � / idna-convert/src/NamePrep/NamePrepInterface.phpnu �[��� <?php namespace Algo26\IdnaConvert\NamePrep; interface NamePrepInterface { /** * @param array $inputArray * * @return array */ public function do(array $inputArray): array; } PK ! �Up p 6 idna-convert/src/NamePrep/CaseFoldingDataInterface.phpnu �[��� <?php declare(strict_types=1); namespace Algo26\IdnaConvert\NamePrep; interface CaseFoldingDataInterface { } PK ! �l�9�+ �+ &