Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wpforms-.../vendor_p.../true/punycode/src
File: Punycode.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace WPForms\Vendor\TrueBV;
[2] Fix | Delete
[3] Fix | Delete
use WPForms\Vendor\TrueBV\Exception\DomainOutOfBoundsException;
[4] Fix | Delete
use WPForms\Vendor\TrueBV\Exception\LabelOutOfBoundsException;
[5] Fix | Delete
/**
[6] Fix | Delete
* Punycode implementation as described in RFC 3492
[7] Fix | Delete
*
[8] Fix | Delete
* @link http://tools.ietf.org/html/rfc3492
[9] Fix | Delete
*/
[10] Fix | Delete
class Punycode
[11] Fix | Delete
{
[12] Fix | Delete
/**
[13] Fix | Delete
* Bootstring parameter values
[14] Fix | Delete
*
[15] Fix | Delete
*/
[16] Fix | Delete
const BASE = 36;
[17] Fix | Delete
const TMIN = 1;
[18] Fix | Delete
const TMAX = 26;
[19] Fix | Delete
const SKEW = 38;
[20] Fix | Delete
const DAMP = 700;
[21] Fix | Delete
const INITIAL_BIAS = 72;
[22] Fix | Delete
const INITIAL_N = 128;
[23] Fix | Delete
const PREFIX = 'xn--';
[24] Fix | Delete
const DELIMITER = '-';
[25] Fix | Delete
/**
[26] Fix | Delete
* Encode table
[27] Fix | Delete
*
[28] Fix | Delete
* @param array
[29] Fix | Delete
*/
[30] Fix | Delete
protected static $encodeTable = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
[31] Fix | Delete
/**
[32] Fix | Delete
* Decode table
[33] Fix | Delete
*
[34] Fix | Delete
* @param array
[35] Fix | Delete
*/
[36] Fix | Delete
protected static $decodeTable = array('a' => 0, 'b' => 1, 'c' => 2, 'd' => 3, 'e' => 4, 'f' => 5, 'g' => 6, 'h' => 7, 'i' => 8, 'j' => 9, 'k' => 10, 'l' => 11, 'm' => 12, 'n' => 13, 'o' => 14, 'p' => 15, 'q' => 16, 'r' => 17, 's' => 18, 't' => 19, 'u' => 20, 'v' => 21, 'w' => 22, 'x' => 23, 'y' => 24, 'z' => 25, '0' => 26, '1' => 27, '2' => 28, '3' => 29, '4' => 30, '5' => 31, '6' => 32, '7' => 33, '8' => 34, '9' => 35);
[37] Fix | Delete
/**
[38] Fix | Delete
* Character encoding
[39] Fix | Delete
*
[40] Fix | Delete
* @param string
[41] Fix | Delete
*/
[42] Fix | Delete
protected $encoding;
[43] Fix | Delete
/**
[44] Fix | Delete
* Constructor
[45] Fix | Delete
*
[46] Fix | Delete
* @param string $encoding Character encoding
[47] Fix | Delete
*/
[48] Fix | Delete
public function __construct($encoding = 'UTF-8')
[49] Fix | Delete
{
[50] Fix | Delete
$this->encoding = $encoding;
[51] Fix | Delete
}
[52] Fix | Delete
/**
[53] Fix | Delete
* Encode a domain to its Punycode version
[54] Fix | Delete
*
[55] Fix | Delete
* @param string $input Domain name in Unicode to be encoded
[56] Fix | Delete
* @return string Punycode representation in ASCII
[57] Fix | Delete
*/
[58] Fix | Delete
public function encode($input)
[59] Fix | Delete
{
[60] Fix | Delete
$input = \mb_strtolower($input, $this->encoding);
[61] Fix | Delete
$parts = \explode('.', $input);
[62] Fix | Delete
foreach ($parts as &$part) {
[63] Fix | Delete
$length = \strlen($part);
[64] Fix | Delete
if ($length < 1) {
[65] Fix | Delete
throw new LabelOutOfBoundsException(\sprintf('The length of any one label is limited to between 1 and 63 octets, but %s given.', $length));
[66] Fix | Delete
}
[67] Fix | Delete
$part = $this->encodePart($part);
[68] Fix | Delete
}
[69] Fix | Delete
$output = \implode('.', $parts);
[70] Fix | Delete
$length = \strlen($output);
[71] Fix | Delete
if ($length > 255) {
[72] Fix | Delete
throw new DomainOutOfBoundsException(\sprintf('A full domain name is limited to 255 octets (including the separators), %s given.', $length));
[73] Fix | Delete
}
[74] Fix | Delete
return $output;
[75] Fix | Delete
}
[76] Fix | Delete
/**
[77] Fix | Delete
* Encode a part of a domain name, such as tld, to its Punycode version
[78] Fix | Delete
*
[79] Fix | Delete
* @param string $input Part of a domain name
[80] Fix | Delete
* @return string Punycode representation of a domain part
[81] Fix | Delete
*/
[82] Fix | Delete
protected function encodePart($input)
[83] Fix | Delete
{
[84] Fix | Delete
$codePoints = $this->listCodePoints($input);
[85] Fix | Delete
$n = static::INITIAL_N;
[86] Fix | Delete
$bias = static::INITIAL_BIAS;
[87] Fix | Delete
$delta = 0;
[88] Fix | Delete
$h = $b = \count($codePoints['basic']);
[89] Fix | Delete
$output = '';
[90] Fix | Delete
foreach ($codePoints['basic'] as $code) {
[91] Fix | Delete
$output .= $this->codePointToChar($code);
[92] Fix | Delete
}
[93] Fix | Delete
if ($input === $output) {
[94] Fix | Delete
return $output;
[95] Fix | Delete
}
[96] Fix | Delete
if ($b > 0) {
[97] Fix | Delete
$output .= static::DELIMITER;
[98] Fix | Delete
}
[99] Fix | Delete
$codePoints['nonBasic'] = \array_unique($codePoints['nonBasic']);
[100] Fix | Delete
\sort($codePoints['nonBasic']);
[101] Fix | Delete
$i = 0;
[102] Fix | Delete
$length = \mb_strlen($input, $this->encoding);
[103] Fix | Delete
while ($h < $length) {
[104] Fix | Delete
$m = $codePoints['nonBasic'][$i++];
[105] Fix | Delete
$delta = $delta + ($m - $n) * ($h + 1);
[106] Fix | Delete
$n = $m;
[107] Fix | Delete
foreach ($codePoints['all'] as $c) {
[108] Fix | Delete
if ($c < $n || $c < static::INITIAL_N) {
[109] Fix | Delete
$delta++;
[110] Fix | Delete
}
[111] Fix | Delete
if ($c === $n) {
[112] Fix | Delete
$q = $delta;
[113] Fix | Delete
for ($k = static::BASE;; $k += static::BASE) {
[114] Fix | Delete
$t = $this->calculateThreshold($k, $bias);
[115] Fix | Delete
if ($q < $t) {
[116] Fix | Delete
break;
[117] Fix | Delete
}
[118] Fix | Delete
$code = $t + ($q - $t) % (static::BASE - $t);
[119] Fix | Delete
$output .= static::$encodeTable[$code];
[120] Fix | Delete
$q = ($q - $t) / (static::BASE - $t);
[121] Fix | Delete
}
[122] Fix | Delete
$output .= static::$encodeTable[$q];
[123] Fix | Delete
$bias = $this->adapt($delta, $h + 1, $h === $b);
[124] Fix | Delete
$delta = 0;
[125] Fix | Delete
$h++;
[126] Fix | Delete
}
[127] Fix | Delete
}
[128] Fix | Delete
$delta++;
[129] Fix | Delete
$n++;
[130] Fix | Delete
}
[131] Fix | Delete
$out = static::PREFIX . $output;
[132] Fix | Delete
$length = \strlen($out);
[133] Fix | Delete
if ($length > 63 || $length < 1) {
[134] Fix | Delete
throw new LabelOutOfBoundsException(\sprintf('The length of any one label is limited to between 1 and 63 octets, but %s given.', $length));
[135] Fix | Delete
}
[136] Fix | Delete
return $out;
[137] Fix | Delete
}
[138] Fix | Delete
/**
[139] Fix | Delete
* Decode a Punycode domain name to its Unicode counterpart
[140] Fix | Delete
*
[141] Fix | Delete
* @param string $input Domain name in Punycode
[142] Fix | Delete
* @return string Unicode domain name
[143] Fix | Delete
*/
[144] Fix | Delete
public function decode($input)
[145] Fix | Delete
{
[146] Fix | Delete
$input = \strtolower($input);
[147] Fix | Delete
$parts = \explode('.', $input);
[148] Fix | Delete
foreach ($parts as &$part) {
[149] Fix | Delete
$length = \strlen($part);
[150] Fix | Delete
if ($length > 63 || $length < 1) {
[151] Fix | Delete
throw new LabelOutOfBoundsException(\sprintf('The length of any one label is limited to between 1 and 63 octets, but %s given.', $length));
[152] Fix | Delete
}
[153] Fix | Delete
if (\strpos($part, static::PREFIX) !== 0) {
[154] Fix | Delete
continue;
[155] Fix | Delete
}
[156] Fix | Delete
$part = \substr($part, \strlen(static::PREFIX));
[157] Fix | Delete
$part = $this->decodePart($part);
[158] Fix | Delete
}
[159] Fix | Delete
$output = \implode('.', $parts);
[160] Fix | Delete
$length = \strlen($output);
[161] Fix | Delete
if ($length > 255) {
[162] Fix | Delete
throw new DomainOutOfBoundsException(\sprintf('A full domain name is limited to 255 octets (including the separators), %s given.', $length));
[163] Fix | Delete
}
[164] Fix | Delete
return $output;
[165] Fix | Delete
}
[166] Fix | Delete
/**
[167] Fix | Delete
* Decode a part of domain name, such as tld
[168] Fix | Delete
*
[169] Fix | Delete
* @param string $input Part of a domain name
[170] Fix | Delete
* @return string Unicode domain part
[171] Fix | Delete
*/
[172] Fix | Delete
protected function decodePart($input)
[173] Fix | Delete
{
[174] Fix | Delete
$n = static::INITIAL_N;
[175] Fix | Delete
$i = 0;
[176] Fix | Delete
$bias = static::INITIAL_BIAS;
[177] Fix | Delete
$output = '';
[178] Fix | Delete
$pos = \strrpos($input, static::DELIMITER);
[179] Fix | Delete
if ($pos !== \false) {
[180] Fix | Delete
$output = \substr($input, 0, $pos++);
[181] Fix | Delete
} else {
[182] Fix | Delete
$pos = 0;
[183] Fix | Delete
}
[184] Fix | Delete
$outputLength = \strlen($output);
[185] Fix | Delete
$inputLength = \strlen($input);
[186] Fix | Delete
while ($pos < $inputLength) {
[187] Fix | Delete
$oldi = $i;
[188] Fix | Delete
$w = 1;
[189] Fix | Delete
for ($k = static::BASE;; $k += static::BASE) {
[190] Fix | Delete
$digit = static::$decodeTable[$input[$pos++]];
[191] Fix | Delete
$i = $i + $digit * $w;
[192] Fix | Delete
$t = $this->calculateThreshold($k, $bias);
[193] Fix | Delete
if ($digit < $t) {
[194] Fix | Delete
break;
[195] Fix | Delete
}
[196] Fix | Delete
$w = $w * (static::BASE - $t);
[197] Fix | Delete
}
[198] Fix | Delete
$bias = $this->adapt($i - $oldi, ++$outputLength, $oldi === 0);
[199] Fix | Delete
$n = $n + (int) ($i / $outputLength);
[200] Fix | Delete
$i = $i % $outputLength;
[201] Fix | Delete
$output = \mb_substr($output, 0, $i, $this->encoding) . $this->codePointToChar($n) . \mb_substr($output, $i, $outputLength - 1, $this->encoding);
[202] Fix | Delete
$i++;
[203] Fix | Delete
}
[204] Fix | Delete
return $output;
[205] Fix | Delete
}
[206] Fix | Delete
/**
[207] Fix | Delete
* Calculate the bias threshold to fall between TMIN and TMAX
[208] Fix | Delete
*
[209] Fix | Delete
* @param integer $k
[210] Fix | Delete
* @param integer $bias
[211] Fix | Delete
* @return integer
[212] Fix | Delete
*/
[213] Fix | Delete
protected function calculateThreshold($k, $bias)
[214] Fix | Delete
{
[215] Fix | Delete
if ($k <= $bias + static::TMIN) {
[216] Fix | Delete
return static::TMIN;
[217] Fix | Delete
} elseif ($k >= $bias + static::TMAX) {
[218] Fix | Delete
return static::TMAX;
[219] Fix | Delete
}
[220] Fix | Delete
return $k - $bias;
[221] Fix | Delete
}
[222] Fix | Delete
/**
[223] Fix | Delete
* Bias adaptation
[224] Fix | Delete
*
[225] Fix | Delete
* @param integer $delta
[226] Fix | Delete
* @param integer $numPoints
[227] Fix | Delete
* @param boolean $firstTime
[228] Fix | Delete
* @return integer
[229] Fix | Delete
*/
[230] Fix | Delete
protected function adapt($delta, $numPoints, $firstTime)
[231] Fix | Delete
{
[232] Fix | Delete
$delta = (int) ($firstTime ? $delta / static::DAMP : $delta / 2);
[233] Fix | Delete
$delta += (int) ($delta / $numPoints);
[234] Fix | Delete
$k = 0;
[235] Fix | Delete
while ($delta > (static::BASE - static::TMIN) * static::TMAX / 2) {
[236] Fix | Delete
$delta = (int) ($delta / (static::BASE - static::TMIN));
[237] Fix | Delete
$k = $k + static::BASE;
[238] Fix | Delete
}
[239] Fix | Delete
$k = $k + (int) ((static::BASE - static::TMIN + 1) * $delta / ($delta + static::SKEW));
[240] Fix | Delete
return $k;
[241] Fix | Delete
}
[242] Fix | Delete
/**
[243] Fix | Delete
* List code points for a given input
[244] Fix | Delete
*
[245] Fix | Delete
* @param string $input
[246] Fix | Delete
* @return array Multi-dimension array with basic, non-basic and aggregated code points
[247] Fix | Delete
*/
[248] Fix | Delete
protected function listCodePoints($input)
[249] Fix | Delete
{
[250] Fix | Delete
$codePoints = array('all' => array(), 'basic' => array(), 'nonBasic' => array());
[251] Fix | Delete
$length = \mb_strlen($input, $this->encoding);
[252] Fix | Delete
for ($i = 0; $i < $length; $i++) {
[253] Fix | Delete
$char = \mb_substr($input, $i, 1, $this->encoding);
[254] Fix | Delete
$code = $this->charToCodePoint($char);
[255] Fix | Delete
if ($code < 128) {
[256] Fix | Delete
$codePoints['all'][] = $codePoints['basic'][] = $code;
[257] Fix | Delete
} else {
[258] Fix | Delete
$codePoints['all'][] = $codePoints['nonBasic'][] = $code;
[259] Fix | Delete
}
[260] Fix | Delete
}
[261] Fix | Delete
return $codePoints;
[262] Fix | Delete
}
[263] Fix | Delete
/**
[264] Fix | Delete
* Convert a single or multi-byte character to its code point
[265] Fix | Delete
*
[266] Fix | Delete
* @param string $char
[267] Fix | Delete
* @return integer
[268] Fix | Delete
*/
[269] Fix | Delete
protected function charToCodePoint($char)
[270] Fix | Delete
{
[271] Fix | Delete
$code = \ord($char[0]);
[272] Fix | Delete
if ($code < 128) {
[273] Fix | Delete
return $code;
[274] Fix | Delete
} elseif ($code < 224) {
[275] Fix | Delete
return ($code - 192) * 64 + (\ord($char[1]) - 128);
[276] Fix | Delete
} elseif ($code < 240) {
[277] Fix | Delete
return ($code - 224) * 4096 + (\ord($char[1]) - 128) * 64 + (\ord($char[2]) - 128);
[278] Fix | Delete
} else {
[279] Fix | Delete
return ($code - 240) * 262144 + (\ord($char[1]) - 128) * 4096 + (\ord($char[2]) - 128) * 64 + (\ord($char[3]) - 128);
[280] Fix | Delete
}
[281] Fix | Delete
}
[282] Fix | Delete
/**
[283] Fix | Delete
* Convert a code point to its single or multi-byte character
[284] Fix | Delete
*
[285] Fix | Delete
* @param integer $code
[286] Fix | Delete
* @return string
[287] Fix | Delete
*/
[288] Fix | Delete
protected function codePointToChar($code)
[289] Fix | Delete
{
[290] Fix | Delete
if ($code <= 0x7f) {
[291] Fix | Delete
return \chr($code);
[292] Fix | Delete
} elseif ($code <= 0x7ff) {
[293] Fix | Delete
return \chr(($code >> 6) + 192) . \chr(($code & 63) + 128);
[294] Fix | Delete
} elseif ($code <= 0xffff) {
[295] Fix | Delete
return \chr(($code >> 12) + 224) . \chr(($code >> 6 & 63) + 128) . \chr(($code & 63) + 128);
[296] Fix | Delete
} else {
[297] Fix | Delete
return \chr(($code >> 18) + 240) . \chr(($code >> 12 & 63) + 128) . \chr(($code >> 6 & 63) + 128) . \chr(($code & 63) + 128);
[298] Fix | Delete
}
[299] Fix | Delete
}
[300] Fix | Delete
}
[301] Fix | Delete
[302] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function