2016-05-13 00:42:28 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IDNA URL encoder
|
|
|
|
*
|
|
|
|
* Note: Not fully compliant, as nameprep does nothing yet.
|
|
|
|
*
|
|
|
|
* @package Requests
|
|
|
|
* @subpackage Utilities
|
2016-06-10 00:50:33 -04:00
|
|
|
* @see https://tools.ietf.org/html/rfc3490 IDNA specification
|
|
|
|
* @see https://tools.ietf.org/html/rfc3492 Punycode/Bootstrap specification
|
2016-05-13 00:42:28 -04:00
|
|
|
*/
|
|
|
|
class Requests_IDNAEncoder {
|
|
|
|
/**
|
|
|
|
* ACE prefix used for IDNA
|
|
|
|
*
|
2016-06-10 00:50:33 -04:00
|
|
|
* @see https://tools.ietf.org/html/rfc3490#section-5
|
2016-05-13 00:42:28 -04:00
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
const ACE_PREFIX = 'xn--';
|
|
|
|
|
|
|
|
/**#@+
|
|
|
|
* Bootstrap constant for Punycode
|
|
|
|
*
|
2016-06-10 00:50:33 -04:00
|
|
|
* @see https://tools.ietf.org/html/rfc3492#section-5
|
2016-05-13 00:42:28 -04:00
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
const BOOTSTRAP_BASE = 36;
|
|
|
|
const BOOTSTRAP_TMIN = 1;
|
|
|
|
const BOOTSTRAP_TMAX = 26;
|
|
|
|
const BOOTSTRAP_SKEW = 38;
|
|
|
|
const BOOTSTRAP_DAMP = 700;
|
|
|
|
const BOOTSTRAP_INITIAL_BIAS = 72;
|
|
|
|
const BOOTSTRAP_INITIAL_N = 128;
|
|
|
|
/**#@-*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Encode a hostname using Punycode
|
|
|
|
*
|
|
|
|
* @param string $string Hostname
|
|
|
|
* @return string Punycode-encoded hostname
|
|
|
|
*/
|
|
|
|
public static function encode($string) {
|
|
|
|
$parts = explode('.', $string);
|
|
|
|
foreach ($parts as &$part) {
|
|
|
|
$part = self::to_ascii($part);
|
|
|
|
}
|
|
|
|
return implode('.', $parts);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a UTF-8 string to an ASCII string using Punycode
|
|
|
|
*
|
|
|
|
* @throws Requests_Exception Provided string longer than 64 ASCII characters (`idna.provided_too_long`)
|
|
|
|
* @throws Requests_Exception Prepared string longer than 64 ASCII characters (`idna.prepared_too_long`)
|
|
|
|
* @throws Requests_Exception Provided string already begins with xn-- (`idna.provided_is_prefixed`)
|
|
|
|
* @throws Requests_Exception Encoded string longer than 64 ASCII characters (`idna.encoded_too_long`)
|
|
|
|
*
|
|
|
|
* @param string $string ASCII or UTF-8 string (max length 64 characters)
|
|
|
|
* @return string ASCII string
|
|
|
|
*/
|
|
|
|
public static function to_ascii($string) {
|
|
|
|
// Step 1: Check if the string is already ASCII
|
|
|
|
if (self::is_ascii($string)) {
|
|
|
|
// Skip to step 7
|
|
|
|
if (strlen($string) < 64) {
|
|
|
|
return $string;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Requests_Exception('Provided string is too long', 'idna.provided_too_long', $string);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Step 2: nameprep
|
|
|
|
$string = self::nameprep($string);
|
|
|
|
|
|
|
|
// Step 3: UseSTD3ASCIIRules is false, continue
|
|
|
|
// Step 4: Check if it's ASCII now
|
|
|
|
if (self::is_ascii($string)) {
|
|
|
|
// Skip to step 7
|
|
|
|
if (strlen($string) < 64) {
|
|
|
|
return $string;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Requests_Exception('Prepared string is too long', 'idna.prepared_too_long', $string);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Step 5: Check ACE prefix
|
|
|
|
if (strpos($string, self::ACE_PREFIX) === 0) {
|
|
|
|
throw new Requests_Exception('Provided string begins with ACE prefix', 'idna.provided_is_prefixed', $string);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Step 6: Encode with Punycode
|
|
|
|
$string = self::punycode_encode($string);
|
|
|
|
|
|
|
|
// Step 7: Prepend ACE prefix
|
|
|
|
$string = self::ACE_PREFIX . $string;
|
|
|
|
|
|
|
|
// Step 8: Check size
|
|
|
|
if (strlen($string) < 64) {
|
|
|
|
return $string;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Requests_Exception('Encoded string is too long', 'idna.encoded_too_long', $string);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether a given string contains only ASCII characters
|
|
|
|
*
|
|
|
|
* @internal (Testing found regex was the fastest implementation)
|
|
|
|
*
|
|
|
|
* @param string $string
|
|
|
|
* @return bool Is the string ASCII-only?
|
|
|
|
*/
|
|
|
|
protected static function is_ascii($string) {
|
|
|
|
return (preg_match('/(?:[^\x00-\x7F])/', $string) !== 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepare a string for use as an IDNA name
|
|
|
|
*
|
|
|
|
* @todo Implement this based on RFC 3491 and the newer 5891
|
|
|
|
* @param string $string
|
|
|
|
* @return string Prepared string
|
|
|
|
*/
|
|
|
|
protected static function nameprep($string) {
|
|
|
|
return $string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a UTF-8 string to a UCS-4 codepoint array
|
|
|
|
*
|
|
|
|
* Based on Requests_IRI::replace_invalid_with_pct_encoding()
|
|
|
|
*
|
|
|
|
* @throws Requests_Exception Invalid UTF-8 codepoint (`idna.invalidcodepoint`)
|
|
|
|
* @param string $input
|
|
|
|
* @return array Unicode code points
|
|
|
|
*/
|
|
|
|
protected static function utf8_to_codepoints($input) {
|
|
|
|
$codepoints = array();
|
|
|
|
|
|
|
|
// Get number of bytes
|
|
|
|
$strlen = strlen($input);
|
|
|
|
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// phpcs:ignore Generic.CodeAnalysis.JumbledIncrementer -- This is a deliberate choice.
|
2016-05-13 00:42:28 -04:00
|
|
|
for ($position = 0; $position < $strlen; $position++) {
|
|
|
|
$value = ord($input[$position]);
|
|
|
|
|
|
|
|
// One byte sequence:
|
|
|
|
if ((~$value & 0x80) === 0x80) {
|
|
|
|
$character = $value;
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
$length = 1;
|
2016-05-13 00:42:28 -04:00
|
|
|
$remaining = 0;
|
|
|
|
}
|
|
|
|
// Two byte sequence:
|
|
|
|
elseif (($value & 0xE0) === 0xC0) {
|
|
|
|
$character = ($value & 0x1F) << 6;
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
$length = 2;
|
2016-05-13 00:42:28 -04:00
|
|
|
$remaining = 1;
|
|
|
|
}
|
|
|
|
// Three byte sequence:
|
|
|
|
elseif (($value & 0xF0) === 0xE0) {
|
|
|
|
$character = ($value & 0x0F) << 12;
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
$length = 3;
|
2016-05-13 00:42:28 -04:00
|
|
|
$remaining = 2;
|
|
|
|
}
|
|
|
|
// Four byte sequence:
|
|
|
|
elseif (($value & 0xF8) === 0xF0) {
|
|
|
|
$character = ($value & 0x07) << 18;
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
$length = 4;
|
2016-05-13 00:42:28 -04:00
|
|
|
$remaining = 3;
|
|
|
|
}
|
|
|
|
// Invalid byte:
|
|
|
|
else {
|
|
|
|
throw new Requests_Exception('Invalid Unicode codepoint', 'idna.invalidcodepoint', $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($remaining > 0) {
|
|
|
|
if ($position + $length > $strlen) {
|
|
|
|
throw new Requests_Exception('Invalid Unicode codepoint', 'idna.invalidcodepoint', $character);
|
|
|
|
}
|
|
|
|
for ($position++; $remaining > 0; $position++) {
|
|
|
|
$value = ord($input[$position]);
|
|
|
|
|
|
|
|
// If it is invalid, count the sequence as invalid and reprocess the current byte:
|
|
|
|
if (($value & 0xC0) !== 0x80) {
|
|
|
|
throw new Requests_Exception('Invalid Unicode codepoint', 'idna.invalidcodepoint', $character);
|
|
|
|
}
|
|
|
|
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
--$remaining;
|
|
|
|
$character |= ($value & 0x3F) << ($remaining * 6);
|
2016-05-13 00:42:28 -04:00
|
|
|
}
|
|
|
|
$position--;
|
|
|
|
}
|
|
|
|
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
if (// Non-shortest form sequences are invalid
|
|
|
|
$length > 1 && $character <= 0x7F
|
2016-05-13 00:42:28 -04:00
|
|
|
|| $length > 2 && $character <= 0x7FF
|
|
|
|
|| $length > 3 && $character <= 0xFFFF
|
|
|
|
// Outside of range of ucschar codepoints
|
|
|
|
// Noncharacters
|
|
|
|
|| ($character & 0xFFFE) === 0xFFFE
|
|
|
|
|| $character >= 0xFDD0 && $character <= 0xFDEF
|
|
|
|
|| (
|
|
|
|
// Everything else not in ucschar
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
$character > 0xD7FF && $character < 0xF900
|
2016-05-13 00:42:28 -04:00
|
|
|
|| $character < 0x20
|
|
|
|
|| $character > 0x7E && $character < 0xA0
|
|
|
|
|| $character > 0xEFFFD
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
throw new Requests_Exception('Invalid Unicode codepoint', 'idna.invalidcodepoint', $character);
|
|
|
|
}
|
|
|
|
|
|
|
|
$codepoints[] = $character;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $codepoints;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RFC3492-compliant encoder
|
|
|
|
*
|
|
|
|
* @internal Pseudo-code from Section 6.3 is commented with "#" next to relevant code
|
|
|
|
* @throws Requests_Exception On character outside of the domain (never happens with Punycode) (`idna.character_outside_domain`)
|
|
|
|
*
|
|
|
|
* @param string $input UTF-8 encoded string to encode
|
|
|
|
* @return string Punycode-encoded string
|
|
|
|
*/
|
|
|
|
public static function punycode_encode($input) {
|
|
|
|
$output = '';
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// let n = initial_n
|
2016-05-13 00:42:28 -04:00
|
|
|
$n = self::BOOTSTRAP_INITIAL_N;
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// let delta = 0
|
2016-05-13 00:42:28 -04:00
|
|
|
$delta = 0;
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// let bias = initial_bias
|
2016-05-13 00:42:28 -04:00
|
|
|
$bias = self::BOOTSTRAP_INITIAL_BIAS;
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// let h = b = the number of basic code points in the input
|
|
|
|
$h = 0;
|
|
|
|
$b = 0; // see loop
|
|
|
|
// copy them to the output in order
|
2016-05-13 00:42:28 -04:00
|
|
|
$codepoints = self::utf8_to_codepoints($input);
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
$extended = array();
|
2016-05-13 00:42:28 -04:00
|
|
|
|
|
|
|
foreach ($codepoints as $char) {
|
|
|
|
if ($char < 128) {
|
|
|
|
// Character is valid ASCII
|
|
|
|
// TODO: this should also check if it's valid for a URL
|
|
|
|
$output .= chr($char);
|
|
|
|
$h++;
|
|
|
|
}
|
|
|
|
// Check if the character is non-ASCII, but below initial n
|
|
|
|
// This never occurs for Punycode, so ignore in coverage
|
|
|
|
// @codeCoverageIgnoreStart
|
|
|
|
elseif ($char < $n) {
|
|
|
|
throw new Requests_Exception('Invalid character', 'idna.character_outside_domain', $char);
|
|
|
|
}
|
|
|
|
// @codeCoverageIgnoreEnd
|
|
|
|
else {
|
|
|
|
$extended[$char] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$extended = array_keys($extended);
|
|
|
|
sort($extended);
|
|
|
|
$b = $h;
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// [copy them] followed by a delimiter if b > 0
|
2016-05-13 00:42:28 -04:00
|
|
|
if (strlen($output) > 0) {
|
|
|
|
$output .= '-';
|
|
|
|
}
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// {if the input contains a non-basic code point < n then fail}
|
|
|
|
// while h < length(input) do begin
|
|
|
|
$codepointcount = count($codepoints);
|
|
|
|
while ($h < $codepointcount) {
|
|
|
|
// let m = the minimum code point >= n in the input
|
2016-05-13 00:42:28 -04:00
|
|
|
$m = array_shift($extended);
|
|
|
|
//printf('next code point to insert is %s' . PHP_EOL, dechex($m));
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// let delta = delta + (m - n) * (h + 1), fail on overflow
|
2016-05-13 00:42:28 -04:00
|
|
|
$delta += ($m - $n) * ($h + 1);
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// let n = m
|
2016-05-13 00:42:28 -04:00
|
|
|
$n = $m;
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// for each code point c in the input (in order) do begin
|
|
|
|
for ($num = 0; $num < $codepointcount; $num++) {
|
2016-05-13 00:42:28 -04:00
|
|
|
$c = $codepoints[$num];
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// if c < n then increment delta, fail on overflow
|
2016-05-13 00:42:28 -04:00
|
|
|
if ($c < $n) {
|
|
|
|
$delta++;
|
|
|
|
}
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// if c == n then begin
|
2016-05-13 00:42:28 -04:00
|
|
|
elseif ($c === $n) {
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// let q = delta
|
2016-05-13 00:42:28 -04:00
|
|
|
$q = $delta;
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// for k = base to infinity in steps of base do begin
|
2016-05-13 00:42:28 -04:00
|
|
|
for ($k = self::BOOTSTRAP_BASE; ; $k += self::BOOTSTRAP_BASE) {
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// let t = tmin if k <= bias {+ tmin}, or
|
|
|
|
// tmax if k >= bias + tmax, or k - bias otherwise
|
2016-05-13 00:42:28 -04:00
|
|
|
if ($k <= ($bias + self::BOOTSTRAP_TMIN)) {
|
|
|
|
$t = self::BOOTSTRAP_TMIN;
|
|
|
|
}
|
|
|
|
elseif ($k >= ($bias + self::BOOTSTRAP_TMAX)) {
|
|
|
|
$t = self::BOOTSTRAP_TMAX;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$t = $k - $bias;
|
|
|
|
}
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// if q < t then break
|
2016-05-13 00:42:28 -04:00
|
|
|
if ($q < $t) {
|
|
|
|
break;
|
|
|
|
}
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// output the code point for digit t + ((q - t) mod (base - t))
|
|
|
|
$digit = $t + (($q - $t) % (self::BOOTSTRAP_BASE - $t));
|
2016-05-13 00:42:28 -04:00
|
|
|
$output .= self::digit_to_char($digit);
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// let q = (q - t) div (base - t)
|
2016-05-13 00:42:28 -04:00
|
|
|
$q = floor(($q - $t) / (self::BOOTSTRAP_BASE - $t));
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
} // end
|
|
|
|
// output the code point for digit q
|
2016-05-13 00:42:28 -04:00
|
|
|
$output .= self::digit_to_char($q);
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// let bias = adapt(delta, h + 1, test h equals b?)
|
2016-05-13 00:42:28 -04:00
|
|
|
$bias = self::adapt($delta, $h + 1, $h === $b);
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// let delta = 0
|
2016-05-13 00:42:28 -04:00
|
|
|
$delta = 0;
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// increment h
|
2016-05-13 00:42:28 -04:00
|
|
|
$h++;
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
} // end
|
|
|
|
} // end
|
|
|
|
// increment delta and n
|
2016-05-13 00:42:28 -04:00
|
|
|
$delta++;
|
|
|
|
$n++;
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
} // end
|
2016-05-13 00:42:28 -04:00
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a digit to its respective character
|
|
|
|
*
|
2016-06-10 00:50:33 -04:00
|
|
|
* @see https://tools.ietf.org/html/rfc3492#section-5
|
2016-05-13 00:42:28 -04:00
|
|
|
* @throws Requests_Exception On invalid digit (`idna.invalid_digit`)
|
|
|
|
*
|
|
|
|
* @param int $digit Digit in the range 0-35
|
|
|
|
* @return string Single character corresponding to digit
|
|
|
|
*/
|
|
|
|
protected static function digit_to_char($digit) {
|
|
|
|
// @codeCoverageIgnoreStart
|
|
|
|
// As far as I know, this never happens, but still good to be sure.
|
|
|
|
if ($digit < 0 || $digit > 35) {
|
|
|
|
throw new Requests_Exception(sprintf('Invalid digit %d', $digit), 'idna.invalid_digit', $digit);
|
|
|
|
}
|
|
|
|
// @codeCoverageIgnoreEnd
|
|
|
|
$digits = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
|
|
return substr($digits, $digit, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adapt the bias
|
|
|
|
*
|
2016-06-10 00:50:33 -04:00
|
|
|
* @see https://tools.ietf.org/html/rfc3492#section-6.1
|
2016-05-13 00:42:28 -04:00
|
|
|
* @param int $delta
|
|
|
|
* @param int $numpoints
|
|
|
|
* @param bool $firsttime
|
|
|
|
* @return int New bias
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
*
|
|
|
|
* function adapt(delta,numpoints,firsttime):
|
2016-05-13 00:42:28 -04:00
|
|
|
*/
|
|
|
|
protected static function adapt($delta, $numpoints, $firsttime) {
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// if firsttime then let delta = delta div damp
|
2016-05-13 00:42:28 -04:00
|
|
|
if ($firsttime) {
|
|
|
|
$delta = floor($delta / self::BOOTSTRAP_DAMP);
|
|
|
|
}
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// else let delta = delta div 2
|
2016-05-13 00:42:28 -04:00
|
|
|
else {
|
|
|
|
$delta = floor($delta / 2);
|
|
|
|
}
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// let delta = delta + (delta div numpoints)
|
2016-05-13 00:42:28 -04:00
|
|
|
$delta += floor($delta / $numpoints);
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// let k = 0
|
2016-05-13 00:42:28 -04:00
|
|
|
$k = 0;
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// while delta > ((base - tmin) * tmax) div 2 do begin
|
2016-05-13 00:42:28 -04:00
|
|
|
$max = floor(((self::BOOTSTRAP_BASE - self::BOOTSTRAP_TMIN) * self::BOOTSTRAP_TMAX) / 2);
|
|
|
|
while ($delta > $max) {
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// let delta = delta div (base - tmin)
|
2016-05-13 00:42:28 -04:00
|
|
|
$delta = floor($delta / (self::BOOTSTRAP_BASE - self::BOOTSTRAP_TMIN));
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
// let k = k + base
|
2016-05-13 00:42:28 -04:00
|
|
|
$k += self::BOOTSTRAP_BASE;
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
} // end
|
|
|
|
// return k + (((base - tmin + 1) * delta) div (delta + skew))
|
2016-05-13 00:42:28 -04:00
|
|
|
return $k + floor(((self::BOOTSTRAP_BASE - self::BOOTSTRAP_TMIN + 1) * $delta) / ($delta + self::BOOTSTRAP_SKEW));
|
|
|
|
}
|
External Libraries: Update the Requests library to version `1.8.0`.
While some of the changes in the `1.8.0` release have already been copied to WordPress Core in earlier releases (see [38727], [46258], [47902] and [49382]), this release contains additional improvements, including:
- A significant performance fix when using cURL.
- Improved compliance with RFC2616.
The library has also been moved under the WordPress project’s GitHub organization and can now be found at https://github.com/WordPress/Requests.
Props jrf, dd32, rmccue, justinahinon, netweb, schlessera, TimothyBJacobs, soulseekah, ozh, skithund, carlalexander, travisnorthcutt, desrosj.
Fixes #53101.
Built from https://develop.svn.wordpress.org/trunk@50842
git-svn-id: http://core.svn.wordpress.org/trunk@50451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-11 15:42:02 -04:00
|
|
|
}
|